ple Choices
☑Kizspy.me
☐ A
☐ B
ос
☐ D
(Choose 1
answer)
How can you avoid contradictions in state with this code?
const [isOpen, setls Open] = useState(false);
const [buttonText, setButtonText] = useState(is Open ? "se": "Open");
function toggle() {
setls Open (lisOpen);
setButtonText(is Open ? "Open": "se");
A. The code above is fine as it is.
B. Remove buttonText from state and calculate it dynamically in the render method based on is Open.
C. Keep both is Open and button Text in state but update them separately.
D. Use useEffect to sync button Text with is Open.
I want to in the exam.
LAPTOP RUNNING