import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';
import createHistory from 'history/lib/createBrowserHistory';
import useQueries from 'history/lib/useQueries';
export default canUseDOM ? useQueries(createHistory)({}) : {};
import ReactDOM from 'react-dom';
import Location from './core/Location';
const routes = {
'/': async() => <HomePage />,
'/another': async() => <AnotherPage />
};
Location.listen(location => {
const component = await routes[location.pathname]();
ReactDOM.render(component, document.body);
});
import React from 'react';
import Location from '../core/Location';
class Link {
handleClick(event) {
event.preventDefault();
Location.pushState(null, event.target.href);
}
render() {
const { children, ...props } = this.props;
return <a onClick={handleClick} {...props}>{children}</a>;
}
}
export default Link;
See the full sample in react-starter-kit!