Closed ghost closed 6 years ago
hi @Ctaque!
it looks as though you're missing a <Router>
instance in your application tree; in your code, on line four, you are importing BrowserRouter as Router,
–you just need to add that to you app. something like this should work:
const App = ({ data }) => (
<Router>
<div>
<ul>
<li><Link to="/">Accueil</Link></li>
<li><Link to="/studies">Etudes</Link></li>
<li><Link to="/experiences">Expériences</Link></li>
<li><Link to="/skills">Competences</Link></li>
<li><Link to="/hobbies">Loisirs</Link></li>
</ul>
<AnimatedSwitch
atEnter={{ opacity: 0 }}
atLeave={{ opacity: 0 }}
atActive={{ opacity: 1 }}
className="switch-wrapper"
>
<Route exact path="/" render={(props) => (<Home home={data.home} {...props}/>)}/>
<Route path="/studies" render={(props) => (<Studies studies={data.studies} {...props}/>)}/>
<Route path="/experiences" render={(props) => (<Experiences experiences={data.experiences} {...props}/>)}/>
<Route path="/skills" render={(props) => (<Skills skills={data.skills} {...props}/>)}/>
<Route path="/hobbies" render={(props) => (<Hobbies hobbies={data.hobbies} {...props}/>)}/>
</AnimatedSwitch>
</div>
</Router>
)
it's also worth pointing out that the only valid children of a Switch
are Route
instances, so i went ahead and changed that for you as well.
let me know if you run into anything else. :v:
Ok thanks. I was thinking that < AnimatedSwitch > was in replacement of < Router >, because < Router > is missing in the example in the readme. (I'm new to React)
that's good feedback, i'll have to spell that out better in the readme. thanks!
I implemented the readme example in a create-react-app application I created today and compilation gives me this error :
this is the component :
Am i missing something?