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

Don't re render on hash anchors from markdown wrapper #462

Closed
f0rr0 opened this issue Sep 24, 2016 · 7 comments
Closed

Don't re render on hash anchors from markdown wrapper #462

f0rr0 opened this issue Sep 24, 2016 · 7 comments

Comments

@f0rr0
Copy link

f0rr0 commented Sep 24, 2016

This should be set by default. Markdown headings usually have anchor hashes. The component gets re-rendered if the hash link is clicked.

@KyleAMathews
Copy link
Contributor

Oh? Didn't realize this. How do you stop the rerender? Some react-router config?

@KyleAMathews
Copy link
Contributor

related: #386

@emilyaviva
Copy link
Contributor

emilyaviva commented Sep 24, 2016

What about https://github.com/adjohnson916/anchorate? (I see @ivanoats already pointed to this in the #386)

@f0rr0
Copy link
Author

f0rr0 commented Sep 24, 2016

@KyleAMathews a naive way could be to intercept links with #something in componentDidMount and then

document.querySelector(`#${something}`).scrollIntoView();

@f0rr0
Copy link
Author

f0rr0 commented Sep 24, 2016

that could be followed up with:

window.history.pushState(null, null, `#${something}`);

However, the back button does not seem to work as expected

@f0rr0
Copy link
Author

f0rr0 commented Sep 25, 2016

I think this issue was being faced by Phenomic as well taion/react-router-scroll#37

The behavior I am seeing is the same as mentioned in the issue above

@KyleAMathews
Copy link
Contributor

On not re-rendering, just was investigating this — easiest solution is to add a shouldComponentUpdate on routes and don't render on hash changes. This is possibly something Gatsby could add automatically as we generate the routes and could wrap them with a sCU like this.

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

No branches or pull requests

3 participants