Learn React Js MCQs
Prepare React Js MCQs (Multiple choice Questions) for exam and job interviews.
What is the purpose of `useEffect` dependency array?
1) To control when the effect runs
2) To manage state
3) To create refs
4) To handle events
Answer : Option 1
How do you optimize rendering for lists?
1) By using `key` prop and `React.memo`
2) By using global state
3) By using refs
4) By using state
Answer : Option 1
How can you style components in React?
1) By using inline styles, CSS Modules, or styled-components
2) By using global styles only
3) By using static styles
4) By using context
Answer : Option 1
What is the difference between `state` and `props`?
1) State is local and mutable, while props are external and immutable
2) Props can be changed, while state cannot
3) State is global, while props are local
4) Both are the same
Answer : Option 1
How do you update the state in a functional component?
1) By using the state updater function returned by `useState`
2) By directly modifying the state
3) By using props
4) By using refs
Answer : Option 1
What does `useEffect` run by default?
1) After every render
2) Only once
3) Only on mount
4) Only on unmount
Answer : Option 1
What is the purpose of `ReactDOM.hydrate`?
1) To hydrate a server-rendered React application
2) To render a component
3) To manage state
4) To handle side effects
Answer : Option 1
How do you avoid unnecessary renders?
1) By using `shouldComponentUpdate` or `React.memo`
2) By using props
3) By using state
4) By using refs
Answer : Option 1
What is the use of `React.createContext`?
1) To create a Context object for managing global state
2) To manage local state
3) To handle side effects
4) To create refs
Answer : Option 1
How do you implement code splitting in React?
1) By using dynamic imports with `React.lazy`
2) By using static imports
3) By using context
4) By using global variables
Answer : Option 1