Modify the below React component named ToggleResetComponent such that the toggle button switches between true and false using the useState hook. Additionally, include a reset button that sets the state back to false. Fill in the blanks with the correct code such that it works as expected.
State
Toggle buttons
Report a typo
Fill in the gaps with the relevant elements
import React, { } from 'react';
const = () => {
const [isToggled, setIsToggled] = useState(false);
const reset = () => {
};
return (
<div>
<p>State: {isToggled ? 'True' : 'False'}</p>
<button onClick={() => setIsToggled(!isToggled)}>Toggle</button>
<button onClick={reset}>Reset</button>
</div>
);
};
export default ToggleResetComponent;Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.