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, { Component } from 'react'; | |
import Progress from 'components/Progress'; | |
import ProgressInput from 'components/ProgressInput'; | |
class App extends Component { | |
state = { | |
count: 10 | |
} | |
onChangeCount = 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
import React, { Component } from 'react'; | |
import CurrentTime from 'components/CurrentTime'; | |
class CurrentYear extends Component { | |
render() { | |
const { time } = this.props; | |
return <div>{time.getFullYear()}</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, { Component, createElement } from 'react'; | |
class CurrentTime extends Component { | |
state = { | |
time: new Date() | |
} | |
tick = () => { | |
this.setState({time: new Date()}) | |
} |
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
class ComponentThatsGenerateAValue extends Component { | |
state = { | |
value: initialState | |
} | |
onChange = newState => { | |
this.setState({value: newState}) | |
} | |
render() { |
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
export default const withRouter = (OriginalComponent) => { | |
class NewComponent extends Component { | |
state = { | |
router: initialRouter | |
} | |
anotherFunc = () => { | |
... |
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 myComponent = ({router, anotherFunc}) => { | |
... | |
} | |
export default withRouter(myComponent); |
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
class MyOtherComponent extends Component { | |
// router e anotherFunc estará disponível dentro de this.props. | |
componentDidMount() { | |
this.props.anotherFunc(); | |
} | |
} | |
export default withRouter(MyOtherComponent); |
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
withA(withB(withC(FinalComponent))); |
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
class Router extends Component { | |
state = { | |
router: initialRouter | |
} | |
render() { | |
createElement(this.props.component, this.state) | |
} | |
} |
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'; | |
import ReactDOM from 'react-dom'; | |
import {Editor, EditorState} from 'draft-js'; | |
class App extends React.Component { | |
state = { | |
editorState: EditorState.createEmpty() | |
} | |
onChange = editorState => this.setState({editorState}) |