Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prev.params should always exist #227

Merged
merged 1 commit into from
Aug 23, 2016
Merged

prev.params should always exist #227

merged 1 commit into from
Aug 23, 2016

Conversation

timwis
Copy link
Member

@timwis timwis commented Aug 20, 2016

The code I suggested in #166 (comment) requires you check if prev.params exists before checking one of its properties, otherwise you'll throw a runtime error on the first load.

const view = (state, prev, send) => {
  if (!prev.params || !prev.params.user || prev.params.user !== state.params.user) {
    send('fetch', state.params.user)
  }
  return html`<div>...</div>`
}

This pull request lets you always check properties of prev.params:

const view = (state, prev, send) => {
  if (!prev.params.user || prev.params.user !== state.params.user) {
    send('fetch', state.params.user)
  }
  return html`<div>...</div>`
}

@yoshuawuyts
Copy link
Member

yoshuawuyts commented Aug 21, 2016

💯 yeah nice one - patch version I reckon?

@timwis timwis merged commit e44f961 into choojs:master Aug 23, 2016
@timwis timwis deleted the prev.params branch August 23, 2016 09:45
@yoshuawuyts
Copy link
Member

Wooh!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants