-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store from Redux provider unavailable in connected react-pixi-fiber components #93
Comments
@nstolpe thanks for the report. If you are using |
Thanks for getting back to me so quickly @michalochman. I'll give some of the workarounds in the PR comment, shoulda looked at some closed issues for more info (I'll close this too). |
I was able to get back to this and solved the issue thanks to those links, using something like this: const ScreenContext = createContext();
const TestContainer = props => {
// react-pixi-fiber Container
return (<Container name="TestContainer" position={props.testContainerPosition} />);
};
const mapStateToProps = (state, ownProps) => ({ ...state });
const ConnectedTestContainer = connect(mapStateToProps, null, null, { context: ScreenContext })(TestContainer);
const Screen = props => (
<ReactReduxContext.Consumer>{({ store }) =>
<Stage>
<AppContext.Consumer>{app => (
<Provider store={store} context={props.context}>{props.children}</Provider>
)}</AppContext.Consumer>
</Stage>
}</ReactReduxContext.Consumer>
);
render(
<Provider store={store}>
<AppWrapper>
<ScreenWrapper>
<Screen context={ScreenContext}>
<TestContainer />
</Screen>
</ScreenWrapper>
<ConnectedControls />
</AppWrapper>
</Provider>,
appContainer
);
Thanks again for the help. |
Thanks for sharing that @nstolpe! |
Hi guys, I'm struggling to integrate redux in my react-pixi-fiber demo, anyone have a demo of a simple integration that I can look? Thanks! |
@ygorlf see the simplest example I could come up with: https://codesandbox.io/s/react-pixi-fiber-with-redux-g4k7n |
|
I'm having issues using redux
connect
on react-pixi-fiber components if the redux provider is not a child of theStage
component.The following setup works for me:
However, if I move the
Provider
so that it wrapsStage
I get this error:
Uncaught Error: Could not find "store" in the context of "Connect(TestContainer)". Either wrap the root component in a <Provider>, or pass a custom React context provider to <Provider> and the corresponding React context consumer to Connect(TestContainer) in connect options.
Ideally I'd like
But it gives me the same error as above.
I can work around this by not using
connect
onTestContainer
and instead just passing props down to it (When the reduxProvider
is used inindex.js
, the connectedTest
component does have access to the props from the store), but it would be simpler to use it with connect.I came across this issue in a similar project (that references pixi-react-fiber, so may be at least partially based on it). Comments there indicate that it's a problem with context in general and not specifically redux. The empty objects here and here look like it might be something similar.
I did a little debugging, but couldn't figure anything out. If this is a solvable issue, I'd love to help out if any contributors could give me some pointers.
The text was updated successfully, but these errors were encountered: