class App extends React.Component {
render() {
return (
<div>
<h1>Slot Machines!</h1>
<Machine
s1="●"
s2="★"
s3="◆"
/>
<Machine
s1="●"
s2="●"
s3="●"
/>
<Machine
s1="●"
s2="★"
s3="★"
/>
</div>
);
}
}
ReactDOM.render(<App />, document.getElementById('root'));
class Machine extends React.Component {
render() {
const { s1, s2, s3 } = this.props;
let win = (s1 === s2 && s2 === s3);
return (
<div>
<p>{s1}{s2}{s3}</p>
<p>{win ? 'win' : 'lose'}</p>
</div>
);
}
}
'react' 카테고리의 다른 글
Props : default props (0) | 2020.06.13 |
---|---|
Props : looping props (0) | 2020.06.13 |
Props : types of props (0) | 2020.06.13 |
Introducing Props! and more.. (0) | 2020.06.13 |
Introducing JSX : basic concept of React layout (0) | 2020.06.13 |