import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import App from './App'; import preco from './Preco'; import NotFound from './NotFound'; import Autores from './Autores'; import Livros from './Livros'; import { BrowserRouter, Switch, Route } from 'react-router-dom'; import * as serviceWorker from './serviceWorker';
ReactDOM.render(
<BrowserRouter>
<Switch>
<Route path="/" exect={true} component={App}/>
<Route path="/preco" component={preco}/>
<Route path="/livros" component={Livros}/>
<Route path="/autores" component={Autores}/>
<Route component={NotFound}/>
</Switch>
</BrowserRouter>,
document.getElementById('root') );
// If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: https://bit.ly/CRA-PWA serviceWorker.unregister();
ex: de uma das paginas:
const Livros = () =>{ return(
Pagina de Livros
); }export default Livros;
import React from 'react'; import LinkWrapper from './LinkWrapper';
const Header = () => {
return (
<nav>
<div className="nav-wrapper indigo accent-4">
<LinkWrapper to="/" className="brand-logo ml-3">Casa do Código</LinkWrapper>
<ul className="right">
<li><LinkWrapper to="/autores">Autores</LinkWrapper></li>
<li><LinkWrapper to="/livros">Livros</LinkWrapper></li>
<li><LinkWrapper to="/preco">Preços</LinkWrapper></li>
</ul>
</div>
</nav>
);
} export default Header;
import React from 'react'; import { NavLink } from 'react-router-dom';
const LinkWrapper = props => { return( <NavLink activeStyle={{fontWeight: "bold"}} {...props}/> ); } export default LinkWrapper;