Question · JavaScript and React course · Module 5: useEffect and Custom Hooks
Testing State and Events
What is the best way to test state changes in a React component?
Answer options
- Simulate a user interaction (e.g., click) and verify that the UI updated as expected
- Directly modify the component state in the test and check the rendering
- Test only internal state variables, without checking the UI
- Check whether useState was called with the correct arguments
You can check the correct answer by solving this task in the CodeWorlds game.