Não consegui implementar o import
{matchPattern} from 'react-router/lib/PatternUtils';
react-router não está funcionando mais... :/
meu código está assim
import {BrowserRouter as Router, Route, Switch, Redirect} from 'react-router-dom'
function verificaUsuarioLogado()
{
if(localStorage.getItem('auth-token') === null){
return false
}
return true;
}
function PrivateRoute({ component: Component, ...rest }) {
return (
<Route
{...rest}
render={props =>
verificaUsuarioLogado() ? (
<Component {...props} />
) : (
<Redirect to={{ pathname: "/", state: { from: props.location } }}
/>
)
}
/>
);
}
ReactDOM.render(
(
<Router>
<Switch>
<Route exact path="/" component={Login} />
<Route path="/logout" component={Logout} />
<Route path="/timeline(/:login)" component={App} />
<PrivateRoute path="/timeline" component={App} onEnter={verificaUsuarioLogado} />
</Switch>
</Router>
),
document.getElementById('root')
);