Document that setting a previously undefined property does not trigger a re-render.
See original GitHub issueHi
I just stumbled upon a small “nice-to-know”.
If using useGlobal()
in a simple (functional/stateless) component, the global state settings your are accessing must be initalized prior to the call to useGlobal()
. This might be obvious to some, but I was wondering why my component would not re-render itself when updating the global, but as soon as I made sure to initialize the global beforehand, it started working.
Apparently this is not mentioned in the documentation, but if it is, then my apologies.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
React - How to force a function component to render?
Updating the value by its setter will force your function component to re-render, just like forceUpdate does: import React, { useState } from...
Read more >Formik does not re-render when initialValues change #811
When initialValues change, Formik should trigger a re-render and provide new initialValues in its render method. CodeSandbox Link:
Read more >API @hookstate/core
It returns the same result as State.get method. This property is more useful than get method for the cases, when a value may...
Read more >JavaScript Data Grid: Cell Renderer - AG Grid
Data property can be undefined when row grouping or loading infinite row models. ... If you do not want to handle the refresh...
Read more >How To Manage State with Hooks on React Components
React Hooks are a broad set of tools in the React front-end JavaScript library that run ... Start by creating a component with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks the explanation, that makes perfect sense and I agreed with your decision to not use proxies for now. I wouldn’t regard this as any issue or drawback for using ReactN, it’s only nice to know beforehand, then it’s quite easy to initialise the state 😃
As a side note I must compliment your work on ReactN - we are moving from React with Redux to React with hooks and ReactN and so far the feeling is much better and the code much less cluttered 😃
Hm, there is no way
<Badge />
is mounted before that call. I had to resort to using thewithGlobal
method.