Skip to content
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

Konva is hijacking React context and not allowing other context providers #446

Closed
chrisjpatty opened this issue Feb 25, 2020 · 6 comments
Closed

Comments

@chrisjpatty
Copy link

When using Context in React, Konva apparently hijacks the context tree in a way that prevents an providers wrapping the stage from ever updating from their default values. In this Code Sandbox example you can see that according to the rules of context, the rectangle should render as red, even though the default value of the context is blue. Because the default is never overwritten, the rectangle renders as blue, even though a value of "red" is being passed to the context provider.

@ejarzo
Copy link
Contributor

ejarzo commented Feb 25, 2020

You will likely need to 'bridge' the context through the Konva Stage - more discussion and example here: #188 (comment)

@chrisjpatty
Copy link
Author

That makes sense thanks. can I suggest that this be documented? Konva doesn't throw any warnings when it overrides the normal context functionality, and it may make for some frustrating debugging situations. I'd be happy to put in a pull request for that.

@lavrton
Copy link
Member

lavrton commented Feb 27, 2020

Sure. It will be very good to have documentation in the README.

@Cosmet
Copy link

Cosmet commented Mar 12, 2020

I'm getting the same issue with Redux Providers. Have to place a provider as a child of stage for its children to have have access.

@ejarzo
Copy link
Contributor

ejarzo commented Mar 12, 2020

I have create a PR for adding info to the README: #450 - let me know if I missed anything

@lavrton lavrton closed this as completed Mar 25, 2020
@lavrton
Copy link
Member

lavrton commented Sep 23, 2022

Update on this issue. From react-konva@18.2.2, context bridge should work by default. It will be really cool if someone can try it and provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants