This file contains hidden or 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
| import * as React from 'react'; | |
| interface IProps { | |
| countBy?: number; | |
| } | |
| interface IState { | |
| count: number; | |
| } |
This file contains hidden or 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
| import * as React from 'react'; | |
| import './App.css'; | |
| import Description from './Description'; | |
| import Header from './Header'; | |
| import logo from './logo.svg'; | |
| class App extends React.Component { | |
| public render() { | |
| return ( | |
| <div className="App"> |
This file contains hidden or 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
| const createStore = (reducer, initialState) => { | |
| const store = {}; | |
| store.state = initialState; | |
| store.listeners = []; | |
| store.getState = () => store.state; | |
| store.subscribe = (listener) => { | |
| store.listeners.push(listener); | |
| }; |
This file contains hidden or 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
| // This will be fed into the reducer when the app loads to initialize the state | |
| const getInitialState = () => ({ | |
| todoList: [], | |
| }); | |
| const reducer = (prevState = getInitialState(), action) => { | |
| switch (action.type) { | |
| case 'ADD_TODO': | |
| const nextState = { | |
| todoList: [ |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title></title> | |
| </head> | |
| <body> | |
| <div>Random Count: <span id="count"></span></div> | |
| <script> | |
| const counterNode = document.getElementById('count'); |
This file contains hidden or 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
| const timeline = []; | |
| let activeItem = 0; | |
| const saveTimeline = () => { | |
| timeline.push(store.getState()); | |
| timelineNode.innerHTML = timeline | |
| .map(item => JSON.stringify(item)) | |
| .join('<br/>'); | |
| activeItem = timeline.length - 1; | |
| }; |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title></title> | |
| </head> | |
| <body> | |
| <div>My background color is <span id="background"></span></div> | |
| <div id="debugger"> | |
| <div> |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title></title> | |
| </head> | |
| <body> | |
| <div>My background color is <span id="background"></span></div> | |
| <div id="debugger"> | |
| <div> |
This file contains hidden or 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
| import React from 'react'; | |
| const higherOrderComponent = (WrappedComponent) => { | |
| class HOC extends React.Component { | |
| render() { | |
| return <WrappedComponent />; | |
| } | |
| } | |
| return HOC; |
This file contains hidden or 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
| import React from 'react'; | |
| const higherOrderComponent = (WrappedComponent) => { | |
| class HOC extends React.Component { | |
| render() { | |
| return ( | |
| <WrappedComponent | |
| secretToLife={42} | |
| {...this.props} | |
| />); |