Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // has-navigated.js
- import { Route } from 'react-router-dom'
- let _hasNavigated = false
- class Tracker extends React.Component {
- componentWillReceiveProps(nextProps) {
- if (nextProps.location !== this.props.location) {
- _hasNavigated = true
- }
- }
- render() {
- return null
- }
- }
- export const HasNavigatedRoute = () => (
- <Route component={Tracker}/>
- )
- export const hasNavigated = () => _hasNavigated
- // App.js
- import { HasNavigatedRoute, hasNavigated } from './has-navigated'
- export default () => (
- <div>
- <HasNavigatedRoute/>
- {hasNavigated() ? <NormalApp/> : <FirstVisitApp/>}
- </div>
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement