This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add all useful state specific functions here | |
export class App extends ReactComponent { | |
constructor(props){ | |
super(props) | |
this.state = {products: [{....}]} | |
// | |
_handleRemoveLast() { | |
this.setState({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//implements API, looks like a regular R component | |
//just displays data as JSON | |
//uses JSON-Formatter.js https://github.com/mohsen1/json-formatter-js | |
//bundler must have acess to node_modules/dist/bundle.js | |
//bind in HTML via <script) | |
//JSONViewer.js | |
export class JSONViewer extends React.Component { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//actions.js | |
export const ADD_PRODUCT = 'ADD_PRODUCT'; | |
export const CLEAR_FORM = 'CLEAR_FORM'; | |
.... | |
//NB Reducers MUST be pure functions | |
/* action creators */ | |
export function addProduct(product){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//MainLayout | |
const linkStyle={activeStyle: {color:'red'}} | |
export const MainLayout = props => { | |
<div> | |
... | |
//default Default loser | |
<Link to="/greeting/loser/default" {...LinkStyle}> Welcome,. Loser</Link> | |
//magic taken care of by REACT ROUTER see nested Routes in Router index.js |
OlderNewer