Day 55

in code •  7 years ago 

March 9th, 2018

Hello! Today the React for Beginners Course by Wes Bos I learned about routing in react.
First import:

            import { BrowserRouter, Route, Switch} from 'react-router-dom';

           import Router from "./components/Router";

in the index.js file.

           const Router = () => (
                 <BrowserRouter>
                        <Switch>
                            <Route exact path="/" component = {StorePicker}/>
                           <Route exact path="/store/:storeId" component = {App}/>
                           <Route component = {NotFound}/>
                      </Switch>
                </BrowserRouter>
    );

I also learned about helper and utility functions.

    <input type="text" required placeholder="Store Name" defaultValue={getFunName()}/>

To get them into the right place.
Many things seem simpler in React, I am thinking of using it more in the future.

Cheers!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!