Fill the blank to display the current state value:
import { useState } from 'react'; function Search() { const state = useState("JavaScript"); return <p>{}</p>; }
import { useState } from 'react'; function Search() { const state = useState("JavaScript"); return <p>{}</p>; }
No tests found
The component's state:
contains data props that were defined by the caller of this component
contains data specific to this component that may change over time
provide a way to access DOM nodes or React elements created in the render method
let you group a list of children without adding extra nodes to the DOM
Is it possible to split JSX over multiple lines in React?
import { createRoot } from "react-dom/client"; const element = (<h1>Hello, Kate Simson !</h1>); const root = createRoot(document.getElementById("root")); root.render(element);
import { createRoot } from "react-dom/client"; const element = (<h1>Hello, Kate Simson !</h1>); const root = createRoot(document.getElementById("root")); root.render(element);
yes
no
JSX doesn't allow to use self-closing tags. True or false?
<UserProfile />
true
false
What shows in the paragraph when a user clicks the button?
function MyButton({ x = 10 }) { function handleClick() { x = 20; } return ( <div> <p>{x}</p> <button onClick={handleClick}>click me</button> </div> ); }
function MyButton({ x = 10 }) { function handleClick() { x = 20; } return ( <div> <p>{x}</p> <button onClick={handleClick}>click me</button> </div> ); }
10
20
nothing
throw an error
In React props is:
props
immutable
mutable
import { useState } from 'react'; function MyButton() { const [state, setState] = useState({ x: 1, y: 2 }); const handleClick = () => { setState({ x: 10, y: 20 }); }; return ( <div> <p>{state.x}, {state.y}</p> <button onClick={handleClick}>click me</button> </div> ); }
1, 2
10, 20
1, 20
undefined
Which of the following are proper ways to update local state in a function component in React?
const [state, setState] = useState({ keywords: "" });
setState("keywords", value)
setState(prevState => ({ ...prevState, keywords: value }))
setState(prevState => ({ ...prevState, keywords: value }))
state.keywords = value
state.keywords = value
setState({keywords: value})
setState({keywords: value})
How can local state be initialized in a function component?
initState
useState
createState
bootState
Which Hook can be used to add local state to a function component?
useEffect
useRef
useRef
«1234»