Skip to content

Commit 13b7910

Browse files
author
Jeffrey Lanters
authored
Merge pull request #62 from mattes3/master
Makes it work regardless of exact React version
2 parents 52b388f + 8b6ab92 commit 13b7910

File tree

5 files changed

+38
-18
lines changed

5 files changed

+38
-18
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ logs
1212
*.js
1313
#.ts
1414

15+
dist/
16+
*.tgz
17+
1518
#.github

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,21 @@ export class App extends React.Component {
5353
}
5454
}
5555
```
56+
57+
# Development and test cycle
58+
59+
If you want to modify this package and iteratively test it in inside your application, use the following steps while you're inside the directory of your own application:
60+
61+
```sh
62+
cd ../react-unity-webgl/
63+
npm pack
64+
cd ../yourapp
65+
npm remove react-unity-webgl
66+
npm install ../react-unity-webgl/react-unity-webgl-x.y.z.tgz
67+
```
68+
69+
The "npm pack" command creates a .tgz file exactly the way it would if you were going to publish the package to npm. You can use that .tgz file to install it in your app. That way you can be sure that everything works exactly as it will do when you publish the package, later.
70+
71+
Do not use a symlink-based technique (e.g. with the "npm link" command) because [npm link breaks libraries that are based on React](https://dev.to/vcarl/testing-npm-packages-before-publishing-h7o).
72+
73+
This package here _must not_ have a dependency on React, only a dev dependency on @types/react. Otherwise, the users of this package might install two different versions of React which will lead to problems.

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "react-unity-webgl",
33
"version": "7.1.0",
44
"description": "React Unity WebGL provides an easy solution for embedding Unity WebGL builds in your React application, with two-way communication between your React and Unity application with advanced API's.",
5-
"main": "source/Export.js",
5+
"main": "./dist/Exports.js",
66
"scripts": {
77
"start": "tsc --watch",
88
"compile": "tsc",
@@ -23,10 +23,8 @@
2323
"url": "https://github.com/elraccoone/react-unity-webgl/issues"
2424
},
2525
"homepage": "https://github.com/elraccoone/react-unity-webgl/wiki",
26-
"dependencies": {
27-
"react": "16.4.1"
28-
},
2926
"devDependencies": {
30-
"@types/react": "16.4.1"
27+
"@types/react": "16.4.1",
28+
"typescript": "^3.4.5"
3129
}
3230
}

source/components/Unity.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import IUnityState from "../interfaces/IUnityState";
44
import UnityContent from "../UnityContent";
55
import UnityLoaderService from "../services/UnityLoaderService";
66
import "../declarations/UnityLoader";
7-
import "./declarations/UnityInstance";
8-
import "./declarations/ReactUnityWebgl";
7+
import "../declarations/UnityInstance";
8+
import "../declarations/ReactUnityWebgl";
99

1010
export default class Unity extends React.Component<IUnityProps, IUnityState> {
1111
/**
@@ -136,7 +136,7 @@ export default class Unity extends React.Component<IUnityProps, IUnityState> {
136136
public render(): React.ReactNode {
137137
return React.createElement("div", {
138138
className: this.props.className || "",
139-
ref: ref => (this.htmlElement = ref!),
139+
ref: (ref: any) => (this.htmlElement = ref!),
140140
id: `__ReactUnityWebGL_${this.props.unityContent.uniqueID}__`,
141141
style: {
142142
width: this.props.width || "800px",

tsconfig.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
2-
"compilerOptions": {
3-
"target": "es5",
4-
"module": "commonjs",
5-
"declaration": true,
6-
"declarationMap": true,
7-
"sourceMap": true,
8-
"strict": true,
9-
"esModuleInterop": true
10-
}
11-
}
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "commonjs",
5+
"declaration": true,
6+
"declarationMap": true,
7+
"sourceMap": true,
8+
"strict": true,
9+
"esModuleInterop": true,
10+
"outDir": "dist"
11+
}
12+
}

0 commit comments

Comments
 (0)