DEV Community

loading...

Discussion on: Throw Out Your React State-Management Tools

Collapse
thatzacdavis profile image
Zachary Davis

Have you run into rerendering issues with passing functions that update state via Context? I think one solution is to memoize the functions, but I'm still experimenting with that.

Collapse
bytebodger profile image
Adam Nathaniel Davis Author

No, I haven't run into any issues with that. I haven't used it enough yet to say that there are no issues with it. But my initial tests haven't revealed any problems... so far.

Collapse
bytebodger profile image
Adam Nathaniel Davis Author • Edited

I'm playing around with something today and your question came to mind. If you want the context to be properly updated on state changes, you must be referencing it from within the render() function. I'm gonna do a follow-up post on this soon that will illustrate this. This might be part of the issue you've experienced.

Collapse
thatzacdavis profile image
Zachary Davis

Looking forward to it!

Thread Thread
bytebodger profile image
Adam Nathaniel Davis Author

And... here it is:

dev.to/bytebodger/a-context-api-fr...

It's not radically different from what I already highlighted. But it emphasizes the need to put the context references in the render() function. It also provides a few stylistic improvements to the first post...