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

Add blocked updates guide to website #4757

Merged
merged 4 commits into from
Mar 23, 2017
Merged

Conversation

pshrmn
Copy link
Contributor

@pshrmn pshrmn commented Mar 15, 2017

Hopefully people will have an easier time finding this when it is on the site.

@pshrmn
Copy link
Contributor Author

pshrmn commented Mar 17, 2017

Added some extra information to the blocked updates guide as well. I have been seeing code that makes quite liberal use of withRouter to get around blocks, when they could just receive the location as a prop from a parent.

@timdorr
Copy link
Member

timdorr commented Mar 17, 2017

LGTM. Can someone with access to the site merge and push this out?

@agundermann
Copy link
Contributor

Looks good. Only thing I would change is the PureComponent to sCU => false. With this.props.children, the component would actually not block updates in most scenarios.

@pshrmn
Copy link
Contributor Author

pshrmn commented Mar 19, 2017

@taurose I just wanted the minimum viable example blocker, which PureComponent rendering its children provides. I originally did not include the implementation of the <UpdateBlocker> (and maybe one doesn't need to be included), but I felt that having a small snippet that says "code that looks like this causes this issue" could be useful.

I had considered using sCU in the example, but sCU => false would not work. The sCU implementation would have return true when props change, so it would need to do something like a shallow comparison on the props, but that is essentially re-implementing PureComponent.

class UpdateBlocker extends React.Component {
  shouldComponentUpate(nextProps) {
    return !shallowEqual(this.props, nextProps)
  }

  render() {
    return this.props.children
  }
}

@agundermann
Copy link
Contributor

agundermann commented Mar 19, 2017

Right, I hadn't thought this through. I agree that PureComponent makes more sense than reimplementing it. Still, the (hidden) use of shallowEquals on props in combination with this.props.children bugs me. How about just rendering a <ChildComponent /> or <Route component={ChildComponent} />?

@pshrmn
Copy link
Contributor Author

pshrmn commented Mar 19, 2017

I guess that part of the issue is that I use the same fake component name throughout the guide. It makes more sense up above where it is defined because it is just being passed <NavLink>s. Down below I'm not actually even passing it any children, which would actually cause an error. I can add a second <UpdateBlocker> implementation for that code that makes more sense (probably use a different name as well).

@pshrmn
Copy link
Contributor Author

pshrmn commented Mar 23, 2017

Still getting a number of issues that are solved by pointing to this. Will be nice once its on the site for increased visibility.

@timdorr
Copy link
Member

timdorr commented Mar 23, 2017

I'm in agreement with getting this in as-is too. Imma merge it. dealwithit.gif. 😎

@ryanflorence, @mjackson, @tylermcginnis Can any of you push this out to the website? It would really help out with the issue load lately.

@timdorr timdorr merged commit 7f002d3 into remix-run:master Mar 23, 2017
@mjackson
Copy link
Member

@timdorr I'm on it. Also, need to do some work on the site so it automatically reflects what's on master.

@mjackson
Copy link
Member

But at least for now we can point them to the doc on GitHub. This is the main reason I wanted good docs with real links on GitHub; so we don't always have to wait for the site to be updated.

@pshrmn pshrmn deleted the blocked-site branch March 29, 2017 13:47
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants