Not exposing the render() method? #10824
pathconnected
started this conversation in
Proposals
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, first of all I just wanna say I love the work you are putting on Remix 3.
Coming from the flutter world, I wanted to share this bit of lore. The so called stateful widgets used to have a method called
markNeedsBuild, similar to yourrendermethod. After early experimentation, they decided to provide a different API to users, one calledsetState. From the documentation of this method:Instead of executing code that mutates state and then calling
markNeedsBuild, people doWe are also thought and warned by the linter to check if the component is mounted before toying with the context (this) in case of an async gap, i.e. if we await something asynchronous we need to check a property called
mountedbefore touching the context. This is because the component can get disposed before the async call ends. Regarding setState:Lastly, in the rare cases where we need to update the component without changing state, as it can (rarely) happen with animations, we are told to do:
Not saying you should follow this approach, just wanted to share those decade old thoughts from other people.
Beta Was this translation helpful? Give feedback.
All reactions