Last active
May 23, 2018 17:53
-
-
Save sujin2f/b67485a16c8c3ff0728035789fe2553e to your computer and use it in GitHub Desktop.
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
import React, { Component, Fragment } from 'react'; | |
class Test extends Component { | |
constructor(props) { | |
super(props); | |
this.additioanlMethod = this.additioanlMethod.bind(this); | |
this.state = { | |
property: 'value', | |
}; | |
} | |
componentWillMount() { | |
this.setState({ | |
property: 'value', | |
}); | |
this.forceUpdate(); | |
} | |
componentDidMount() { | |
console.log('componentDidMount'); | |
} | |
componentWillReceiveProps(nextProps) { | |
console.log('componentWillReceiveProps', nextProps); | |
} | |
shouldComponentUpdate(nextProps, nextState) { | |
console.log('shouldComponentUpdate', nextProps, nextState); | |
} | |
componentWillUpdate(nextProps, nextState) { | |
console.log('componentWillUpdate', nextProps, nextState); | |
} | |
componentDidUpdate(prevProps, prevState) { | |
console.log('componentDidUpdate', prevProps, prevState); | |
} | |
componentWillUnmount() { | |
console.log('componentWillUnmount'); | |
} | |
componentDidCatch(error, info) { | |
console.log('componentDidCatch', error, info); | |
} | |
additioanlMethod() {} | |
render() { | |
return ( | |
<Fragment> | |
{ /* eslint-disable react/no-danger */ } | |
<div | |
dangerouslySetInnerHTML={{ | |
__html: notifications[id].message.replace(/\\n/gi, '<br />'), | |
}} | |
/> | |
{ /* eslint-enable react/no-danger */ } | |
</Fragment> | |
); | |
} | |
} | |
Test.defaultProps = { | |
property: 'value', | |
}; | |
Test.displayName = 'Test'; | |
export default Test; |
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
import { connect } from 'react-redux'; | |
import { | |
func, | |
} from 'actions/func'; | |
import Component from 'components/Notification/Component'; | |
const mapStateToProps = state => ({ | |
value: state.value, | |
}); | |
const mapDispatchToProps = dispatch => ({ | |
func: (attr) => { | |
dispatch(func(attr)); | |
}, | |
}); | |
export default connect(mapStateToProps, mapDispatchToProps)(Component); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment