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.

update view API to be (state, prev, send)

See original GitHub issue

Since v2.1.4 (oops, semver) we’re now also passing the oldState down to views. The view api now looks like:

const view = (params, state, send, oldState) => choo.view`
  <main>${params.foo} and ${state.bar}</main>
`

Instead I reckon it might be nicer to have:

const view = (state, oldState, send) => choo.view`
  <main>${state.params.foo} and ${state.bar}</main>
`

This would definitely be a breaking change, but actually not that hard to fix (e.g. we can provide a regex heyyyy). What do people think?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
yoshuawuytscommented, Jun 20, 2016

@timwis yeah, you’re totally right - mentally I’ve been geared to have data go first and any type of callback last, so we should probs just do (state, prev, send)

2reactions
yocontracommented, Jun 20, 2016
// view(context, send)
const view = ({ params, state, oldState }, send) => choo.view`
  <main>${params.foo} and ${state.bar}</main>
`

🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamically Change State-Bound Content on Successful API ...
In this guide, we'll take a look at how to update the rendered content of a component dynamically from data fetched from a...
Read more >
How to update the state after a data update through an API ...
You need to be able to append that new data, body inside item array, means you need to call this setItem(prev => [...prev,...
Read more >
views.update method - Slack API
Update a view by passing a new view definition object along with the view_id returned in views.open or the external_id . See the...
Read more >
How to use componentDidUpdate in React - DEV Community ...
Update components based on comparison of previous and current state. We have seen how the componentDidMount() method is called on class ...
Read more >
Updating Objects in State - React Docs
Replace position with this new object; And render this component again. Notice how the red dot now follows your pointer when you touch...
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