/* eslint-disable react/forbid-prop-types */ import React from 'react'; import PropTypes from 'prop-types'; import {actions, href, isActive, locationHash, locationHistory} from '../../src'; import {createStore} from './store'; const store = createStore(); if (process.env.HISTORY === 'HASH') { // When publishing to GitHub Pages we cannon use HTML5 history navigation locationHash({store, namespace: 'componentRouter'}); } else { locationHistory({store, namespace: 'componentRouter'}); } const navigateTo = params => event => { event.preventDefault(); store.dispatch(actions.navigateTo(params)); }; const GlobalLinks = ({routingState}) => (
); GlobalLinks.propTypes = { routingState: PropTypes.object.isRequired }; class ComponentLinks extends React.Component { static propTypes = { routingState: PropTypes.object.isRequired }; componentDidMount() { store.dispatch(actions.addDefaultParam('component', 'baz')); } componentWillUnmount() { store.dispatch(actions.removeParam('component')); } render() { const {routingState} = this.props; return ( component: bla component: baz ); } } class SortedComponentLinks extends React.Component { static propTypes = { routingState: PropTypes.object.isRequired }; componentDidMount() { store.dispatch(actions.addDefaultParam('offRecord', 'bla')); store.dispatch(actions.addOffRecordParam('offRecord')); } componentWillUnmount() { store.dispatch(actions.removeParam('offRecord')); } render() { const {routingState} = this.props; return ({JSON.stringify(routingState, null, 2)}