Skip to content

Instantly share code, notes, and snippets.

@tvorogme
Created August 23, 2019 16:14
Show Gist options
  • Save tvorogme/7e3cf61a1328f8adbe5df73efa4dbe3d to your computer and use it in GitHub Desktop.
Save tvorogme/7e3cf61a1328f8adbe5df73efa4dbe3d to your computer and use it in GitHub Desktop.
import React from 'react';
import './App.css';
class B extends React.Component {
constructor(props) {
super(props);
this.state = {};
this.state.b = this.props.lolkek
}
static getDerivedStateFromProps(newProps, newState) {
newState.b = newProps.lolkek;
return newState
}
render() {
return (
<div>
{this.state.b}
</div>
);
}
}
class App extends React.Component {
constructor(props) {
super(props);
this.state = {a: 1};
setInterval(() =>
this.setState({a: this.state.a + 1}), 100)
}
handleChange = (nevedomayahreny) => {
this.setState({[nevedomayahreny.target.name]: [nevedomayahreny.target.value]})
};
render() {
return <div>
{['123', '231', '456', '65342'].map((value, index) => <B key={index} lolkek={value}/>)}
</div>
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment