import React from 'react'; import PropTypes from 'prop-types'; /** * * @author Yuki Takei * * @export * @class SlackNotification * @extends {React.Component} */ export default class SlackNotification extends React.Component { constructor(props) { super(props); this.state = { isNotification: false, slackChannels: this.props.slackChannels, }; this.updateState = this.updateState.bind(this); this.updateStateCheckbox = this.updateStateCheckbox.bind(this); } componentWillReceiveProps(nextProps) { this.setState({ slackChannels: nextProps.slackChannels }); console.log('next props'); } updateState(value) { this.setState({slackChannels: value}); this.props.onChannelChange(value); } updateStateCheckbox(event) { const value = event.target.checked; this.setState({isNotification: value}); this.props.onSlackOnChange(value); } render() { return (
this.updateState(e.target.value)} />
); } } SlackNotification.propTypes = { crowi: PropTypes.object.isRequired, pageId: PropTypes.string, pagePath: PropTypes.string, onChannelChange: PropTypes.func.isRequired, onSlackOnChange: PropTypes.func.isRequired, slackChannels: PropTypes.string, };