Skip to content

Commit

Permalink
Manually migrated lifecycle hooks for CoffeeScript and TypeScript tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Jan 16, 2018
1 parent 28a0e4b commit f0e6f62
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe 'ReactCoffeeScriptClass', ->
constructor: (props) ->
@state = bar: props.initialValue

componentWillMount: ->
unsafe_componentWillMount: ->
@setState bar: 'bar'

render: ->
Expand Down Expand Up @@ -232,20 +232,20 @@ describe 'ReactCoffeeScriptClass', ->
constructor: ->
@state = {}

componentWillMount: ->
unsafe_componentWillMount: ->
lifeCycles.push 'will-mount'

componentDidMount: ->
lifeCycles.push 'did-mount'

componentWillReceiveProps: (nextProps) ->
unsafe_componentWillReceiveProps: (nextProps) ->
lifeCycles.push 'receive-props', nextProps

shouldComponentUpdate: (nextProps, nextState) ->
lifeCycles.push 'should-update', nextProps, nextState
true

componentWillUpdate: (nextProps, nextState) ->
unsafe_componentWillUpdate: (nextProps, nextState) ->
lifeCycles.push 'will-update', nextProps, nextState

componentDidUpdate: (prevProps, prevState) ->
Expand Down
8 changes: 4 additions & 4 deletions packages/react/src/__tests__/ReactTypeScriptClass-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class RenderOnce extends React.Component {
state = {
bar: this.props.initialValue,
};
componentWillMount() {
unsafe_componentWillMount() {
this.setState({bar: 'bar'});
}
render() {
Expand Down Expand Up @@ -206,20 +206,20 @@ let lifeCycles = [];
class NormalLifeCycles extends React.Component {
props: any;
state = {};
componentWillMount() {
unsafe_componentWillMount() {
lifeCycles.push('will-mount');
}
componentDidMount() {
lifeCycles.push('did-mount');
}
componentWillReceiveProps(nextProps) {
unsafe_componentWillReceiveProps(nextProps) {
lifeCycles.push('receive-props', nextProps);
}
shouldComponentUpdate(nextProps, nextState) {
lifeCycles.push('should-update', nextProps, nextState);
return true;
}
componentWillUpdate(nextProps, nextState) {
unsafe_componentWillUpdate(nextProps, nextState) {
lifeCycles.push('will-update', nextProps, nextState);
}
componentDidUpdate(prevProps, prevState) {
Expand Down

0 comments on commit f0e6f62

Please sign in to comment.