W3Tutorials.net
Toggle Menu
Home
Online Go Compiler
Tutorials
Javascript Tutorials
Python Tutorials
Go Tutorials
Blog
All Posts
React.js Basics
Quiz yourself on components,props,and state management in React.
1. What is React.js primarily used for?
Building user interfaces
Backend server logic
Database management
Mobile app testing
2. Which syntax is used to embed HTML within JavaScript in React?
HTML-in-JS
JSX
ES6
TypeScript
3. What is the smallest building block of a React application?
Element
Component
Hook
State
4. Which function is used to render a React component to the DOM?
React.render()
ReactDOM.render()
React.createElement()
document.render()
5. What are functional components in React?
Components written as classes
Components written as functions
Components with state
Components with lifecycle methods
6. Which mechanism is used to pass data from a parent to a child component?
State
Props
Hooks
Context
7. What does the useState hook return?
A state variable and a setter function
A state variable only
A setter function only
A boolean value
8. Which lifecycle method runs after a component is inserted into the DOM?
componentWillMount
componentDidMount
componentDidUpdate
componentWillUnmount
9. What is the purpose of the 'key' prop in React lists?
To style list items
To handle click events
To uniquely identify list items
To pass data to list items
10. Which of the following is NOT a valid React component type?
Functional Component
Class Component
Pure Component
Interface Component
11. Which of the following are built-in React hooks? (Select all that apply)
useState
useEffect
useContext
useNavigate
12. Which statements about JSX are true? (Select all that apply)
JSX must return a single root element
JSX allows embedding JavaScript expressions with {}
JSX is required to use React
JSX compiles to React.createElement() calls
13. Which events can trigger a React component to re-render? (Select all that apply)
State updates
Prop changes
Parent component re-renders
Console.log() execution
14. React is a JavaScript framework, not a library.
True
False
15. State in React can be directly modified (e.g., this.state.count = 5).
True
False
16. JSX supports if-else statements directly within the markup.
True
False
17. The useEffect hook can replace lifecycle methods like componentDidMount in functional components.
True
False
18. What does JSX stand for?
19. Name the hook used to access context values in functional components.
20. What method is used to update state in class components?
Reset
Answered 0 of 0 — 0 correct