What's the difference between JSX attributes and HTML attributes?
JSX attributes are used for styling, while HTML attributes are for functionality.
There is no difference, they are the same.
JSX attributes can only be strings, while HTML attributes can be any data type.
JSX attributes are written in camelCase, while HTML attributes are lowercase.
What are props in React?
Arguments passed to a component
Functions to update the UI
Lifecycle methods of a component
Internal data of a component
What is the main difference between functional components and class components in React?
There is no difference; both are interchangeable.
Functional components are used for complex UI, while class components are used for simple UI.
Class components can have state and lifecycle methods, while functional components cannot.
Functional components are written in JavaScript, while class components are written in JSX.
What will happen if you update the state directly in a React component?
The component will re-render, and the state change will be reflected correctly.
An error will be thrown, and the application will crash.
Nothing will happen; the state will remain unchanged.
The component will re-render, but the state change won't be reflected.
What happens if a prop is not provided to a component with a default prop defined?
The component will not render
The prop will be undefined
An error is thrown
The default prop value is used
Why is it generally not recommended to mutate the DOM directly in React?
DOM manipulation is slow and inefficient in modern browsers
React doesn't have access to the DOM, so manipulation is impossible
React's event system automatically prevents DOM manipulation
Direct DOM manipulation can lead to inconsistencies between the actual DOM and React's virtual DOM
How can you access the element that triggered an event within a React event handler?
As a property of the event object (e.g., event.target)
event.target
By passing the element as an argument to the event handler
Using this keyword inside the event handler
this
React doesn't provide a way to access the triggering element
In React functional components, how do you typically handle events?
Events are not handled in functional components, only in class components
By creating separate event listener functions outside the component
By defining methods inside the component class
Using inline event handlers directly in JSX
In JSX, how would you set the 'class' attribute for an element?
What's a common way to bind event handlers in React class components?
Both 'Using bind in the constructor' and 'Using arrow functions in the render method'
bind
render
Using bind in the constructor
Calling addEventListener within the componentDidMount lifecycle method
addEventListener
componentDidMount
Using arrow functions in the render method