-
Notifications
You must be signed in to change notification settings - Fork 18
Conversation
I found a weird thing on the header id jump. For example: But if I hit |
It looks like this issue has been resolved in react-router v4. What do you think about logging this as a seperate issue and fix it when we upgrade to react-router v4? |
I'm fine with logging an issue for when we update RR to v4. Before that can we test the sample code from that issue link for RR v3 for creating a hashLinkScroll function and passing that to the Route onUpdate prop . import React from 'react';
import { render } from 'react-dom';
import { Router, Route, browserHistory } from 'react-router';
const routes = (
// your routes
);
function hashLinkScroll() {
const { hash } = window.location;
if (hash !== '') {
// Push onto callback queue so it runs after the DOM is updated,
// this is required when navigating from a different page so that
// the element is rendered on the page before trying to getElementById.
setTimeout(() => {
const id = hash.replace('#', '');
const element = document.getElementById(id);
if (element) element.scrollIntoView();
}, 0);
}
}
render(
<Router
history={browserHistory}
routes={routes}
onUpdate={hashLinkScroll}
/>,
document.getElementById('root')
) |
+1 to add All other things look good to me. |
Summary
This fixes the react-router URLs. Currently, if you go to https://terra-ui.herokuapp.com/components/core/badge, the route does not exist. This is because this route is generated by react-router. This pr fixes that issue.
This fix is the same thing react_on_rails suggests.
https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/config/routes.rb#L13
Thanks for contributing to Terra.
@cerner/terra