Created
August 23, 2019 16:14
-
-
Save tvorogme/7e3cf61a1328f8adbe5df73efa4dbe3d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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