I need to pass props to component using router. Here's my code:
import React, { Component, PropTypes } from 'react'; import { connect } from 'react-redux'; import AppBarTop from './appbar/AppBarTop'; import Login from '../pages/login/Login'; import {BrowserRouter as Router, Route} from 'react-router-dom'; class App extends Component { render() { const { isAuthenticated } = this.props; return ( ); } }
As you can see, isAuthenticated the prop i want to pass to Login component.
class Login extends Component { constructor(props) { super(props); console.log(props); } render() { return ( ); } } export default connect(null) (Login);
When i log the props the isAuthenticated prop is not there. What i'm doing wrong? How can i pass the prop correctly? I followed the docs and also other discussions. From my understanding it should work. The version of react-router and react-router-dom is 4.0.0