Pass root in second argument to app().
See original GitHub issueThe proposal is to remove the app’s root
property and do the same passing it in the second argument to app().
Before
app({ init, view, state, actions, root })
After
app({ init, view, state, actions }, root)
e.g.
app(
{
init,
view,
state,
actions
},
document.getElementById("app")
)
Pros
- Make app() props have to deal only with the state management side of things.
- Other libraries often do the same, e.g., P/React’s
render(elm, root)
, Elm’sElm.Main.embed(root)
, mithril’sm,mount(document.body, Counter)
(the order is reversed here though), Vue’s$mount
, etc. - Cuts like 10 bytes. 😅
Cons
- There is nothing wrong with the current way of doing things.
Adds like 10 bytes.- Complicates the signature of HOAs. Thanks @okwolf.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:15 (15 by maintainers)
Top Results From Across the Web
You passed a container to the second argument of root.render ...
I had the same problem when i went to React 18 : const root = ReactDOM.createRoot( document.getElementById('root') ); root.render( <React.
Read more >What is the second argument that can optionally be passed to ...
The second argument that can optionally be passed to setState is a callback function which gets called immediately after the setState is ...
Read more >Pass data between destinations - Android Developers
To pass data between destinations, first define the argument by adding it to the destination that receives it by following these steps:.
Read more >How passing props to component works in React
Master how to pass props (properties) to components in React with this useful beginner's guide, including demo code.
Read more >Writing middleware for use in Express apps
Call the next middleware in the stack. If the current middleware function does not end the request-response cycle, it must call next() to...
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 Free
Top 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
I still want to make sure we have consistent reasoning for API changes. As we approach 1.0, the API will become locked.
The real (not really) question is, how do we feel about formatters like prettier making the code this: