Skip to content

Commit

Permalink
Fix context not passed through from primary renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
michalochman committed Nov 10, 2018
1 parent e42768c commit 3482460
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- Fixed React 16.6.0 compatibility ([#71])

### Fixed
- Fixed context not passed through from primary renderer (`react-dom`) into `react-pixi-fiber`


## [0.5.1] - 2018-11-02

Expand Down
4 changes: 2 additions & 2 deletions src/Stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Stage extends React.Component {
const stageProps = getDisplayObjectProps(this.props);
applyProps(this._app.stage, {}, stageProps);

render(<AppProvider app={this._app}>{children}</AppProvider>, this._app.stage);
render(<AppProvider app={this._app}>{children}</AppProvider>, this._app.stage, undefined, this);
}

componentDidUpdate(prevProps, prevState) {
Expand All @@ -90,7 +90,7 @@ class Stage extends React.Component {
this._app.renderer.resize(currentWidth, currentHeight);
}

render(<AppProvider app={this._app}>{children}</AppProvider>, this._app.stage);
render(<AppProvider app={this._app}>{children}</AppProvider>, this._app.stage, undefined, this);
}

componentWillUnmount() {
Expand Down
4 changes: 2 additions & 2 deletions src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ export const roots = new Map();
* element should be any instance of PIXI DisplayObject
* containerTag should be an instance of PIXI root Container (i.e. the Stage)
*/
export function render(element, containerTag, callback) {
export function render(element, containerTag, callback, parentComponent) {
let root = roots.get(containerTag);
if (!root) {
root = ReactPixiFiber.createContainer(containerTag);
roots.set(containerTag, root);
}

ReactPixiFiber.updateContainer(element, root, undefined, callback);
ReactPixiFiber.updateContainer(element, root, parentComponent, callback);

ReactPixiFiber.injectIntoDevTools({
findFiberByHostInstance: ReactPixiFiber.findFiberByHostInstance,
Expand Down
14 changes: 12 additions & 2 deletions test/Stage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ describe("Stage", () => {
const stage = instance._app.stage;

expect(render).toHaveBeenCalledTimes(1);
expect(render).toHaveBeenCalledWith(<AppProvider app={instance._app}>{children}</AppProvider>, stage);
expect(render).toHaveBeenCalledWith(
<AppProvider app={instance._app}>{children}</AppProvider>,
stage,
undefined,
instance
);
});

it("calls render on componentDidUpdate", () => {
Expand All @@ -190,7 +195,12 @@ describe("Stage", () => {
element.update(<Stage>{children2}</Stage>);

expect(render).toHaveBeenCalledTimes(1);
expect(render).toHaveBeenCalledWith(<AppProvider app={instance._app}>{children2}</AppProvider>, stage);
expect(render).toHaveBeenCalledWith(
<AppProvider app={instance._app}>{children2}</AppProvider>,
stage,
undefined,
instance
);
});

it("calls unmount on componentWillUnmount", () => {
Expand Down

0 comments on commit 3482460

Please sign in to comment.