Pierre Ortega
@4ever
1:46am
const Toggle = () => {
const [isToggledOn, setToggle] = useState(false)
const toggle = () => setToggle(!isToggledOn)
return (
<button onClick={toggle}>
{isToggleOn ? 'ON' : 'OFF'}
</button>
)
}
// import React, { useState } from 'react';
const { useState } = React;
function App() {
const [checked, setChecked] = useState(false);
const toggleChecked = () => setChecked(value => !value);
return (
<input
type="checkbox"
checked={checked}
onChange={toggleChecked}
/>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);