Skip to content

Instantly share code, notes, and snippets.

@sujin2f
Last active May 23, 2018 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sujin2f/b67485a16c8c3ff0728035789fe2553e to your computer and use it in GitHub Desktop.
Save sujin2f/b67485a16c8c3ff0728035789fe2553e to your computer and use it in GitHub Desktop.
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;
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