import React, { useState } from 'react';
function State() {
const [color, setColor] = useState('red');
return (
<div>
<h1>Function Component | State</h1>
</div>
);
}
export default State;
import React, { useState } from 'react';
function State() {
const [color, setColor] = useState('red');
return (
<div>
<h1 style={{ color: color }}>Function Component | State</h1>
<button onClick={() => setColor('blue')}>Click</button>
</div>
);
}
export default State;
https://ko.reactjs.org/docs/hooks-state.html