Skip to content

Instantly share code, notes, and snippets.

@Joe1220
Created August 6, 2018 04:43
Show Gist options
  • Save Joe1220/1672ceda5628466882680f07de2aebbf to your computer and use it in GitHub Desktop.
Save Joe1220/1672ceda5628466882680f07de2aebbf to your computer and use it in GitHub Desktop.
App.js
import React, { Component } from "react";
import { Route, Switch } from "react-router-dom";
import Nav from "components/Nav/Nav";
import Cart from "components/Cart/Cart";
import Main from "components/Main/Main";
import data from "MOCK_DATA.json";
class App extends Component {
constructor() {
super();
this.state = {
products: data
};
};
componentDidMount() {
console.log(this.state.products)
};
render() {
return (
<Routes />
);
};
};
const Routes = props => (
<div>
<Nav />
<Switch>
<Route exact path="/" component={Main} />
<Route exact path="/cart" component={Cart} />
</Switch>
</div>
);
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment