Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyComponent {
- componentDidMount() {
- this.props.webSocket.on('myEvent', componentDidReceiveEvent)
- }
- componentWillUnmount() {
- this.props.webSocket.off('myEvent', componentDidReceiveEvent)
- }
- // is this even method style valid syntax?
- componentDidReceiveEvent = limit((evt) => {
- this.state.setState((prev, props) => {
- return {
- ...prev,
- inboundEvents: [...prev.events, evt]
- };
- });
- })
- render() {
- return <div>
- this.state.events.map(e => <MyNode key={evt.id} />)
- </div>
- }
- }
- MyComponent.propTypes = {
- id: React.PropTypes.string,
- webSocket: React.PropTypes.oneOfType([
- React.PropTypes.bool,
- React.PropTypes.object,
- ]),
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement