Monday, 14 May 2018

reactjs - React-router - check for empty state and redirect?

How can I check for empty state and redirect to the first route, if needed?




I have my routes.js



export default (


;







);


and my index.js



const store = configureStore();
console.log({ store });
render(



,
document.getElementById('root')
);


How would I do that using react-router



app.js




import React, { PropTypes } from 'react';
import Header from './common/Header';
import ModalRoot from './modals/Modal';
import Footer from './common/Footer';
class App extends React.Component {
render() {
return (




{this.props.children}


);
}
}

App.propTypes = {
children: PropTypes.object.isRequired,

};

export default App;

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...