question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document that setting a previously undefined property does not trigger a re-render.

See original GitHub issue

Hi

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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kaa4evercommented, Apr 9, 2019

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 😃

0reactions
chrise86commented, May 24, 2019

Hm, there is no way <Badge /> is mounted before that call. I had to resort to using the withGlobal method.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found