Day 55

By @aronson3/9/2018code

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!

1

comments