-
-
Notifications
You must be signed in to change notification settings - Fork 87
setGlobal in componentDidMount should be synchronous. #14
Comments
Why not declaring componentDidMount async and do await setGlobal? |
setState is synchronous in componentDidMount. setGlobal should mimic that behavior. It's just a matter of it being possible in all implementations. You can likely find details from the React team on why setState is synchronous sometimes. I'd love to link it, but I'm restricted to mobile for a little longer as I'm in the process of moving. |
@CharlesStover Are you referring to this comment? |
Hi @CharlesStover , I feel like having a third parameter to force synchronicity could be interesting. As of now, what would be the best way of making synchronous calls to Thank you in advance, |
I'm not sure this is related, but I've noticed that when I setGlobal in componentDidMount (after async fetching of data), it sometimes does not cause the page to render. setGlobal({ myValue: val }, ()=>{
this.forceUpdate()
}) EDIT I figured out my problem. I forgot that reactn requires a default value for global state to trigger a re-render the first time it is changed: #57 |
Also did update and set global callback
Async elsewhere
The text was updated successfully, but these errors were encountered: