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.

Pass root in second argument to app().

See original GitHub issue

The 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’s Elm.Main.embed(root), mithril’s m,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:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
pspeter3commented, Oct 10, 2017

I still want to make sure we have consistent reasoning for API changes. As we approach 1.0, the API will become locked.

1reaction
jorgebucarancommented, Oct 10, 2017

The real (not really) question is, how do we feel about formatters like prettier making the code this:

app(
  { 
    init, 
    view, 
    state, 
    actions 
  }, 
  document.getElementById("app")
)
Read more comments on GitHub >

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

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