opendevs
opendevs logo
CoursesInterviewsBlogs

Props and States

React components can have a state object. The state object is where you store property values / data that belongs to the component. When the state object changes, the component re-renders / refreshes itself to show the new data. Props short for properties, is the optional input that your component can accept. Props are arguments passed into React components. It is passed to components via HTML attributes. It also allows the component content to be dynamic.
Components
Loading video...

Props State - 1 (in Hindi)

Concepts

    1

    Props State - 1 (in Hindi)
    Props State - 1 (in Hindi)

    2

    Props State - 2 (in Hindi)
    Props State - 2 (in Hindi)
Watch the full video to earn  3  DevCoin image

Quizzes


1

What's wrong with the code below? Select all that apply.

function Component() { const [count, setCount] = useState() setCount(count + 1) return <div>Counter value: {count}</div> }
Question 1 of 5
1  DevCoin image   per question
2

What will be the value of the count if the Increment button is clicked once?

function Component() { const [counter, setCounter] = React.useState(0); const handleClick = () => { setCounter(counter + 1); setCounter(counter + 1); } return ( <div style={{ textAlign: "center" }}> <p>Counter App</p> <p>Counter Value: {counter}</p> <button onClick={handleClick}>Increment</button> </div> ); }
Question 1 of 5
1  DevCoin image   per question
3

Using which keyword I can set default props?

Question 1 of 5
1  DevCoin image   per question
4

Which of the following is used to pass data to a component from outside in React.js?

Question 1 of 5
1  DevCoin image   per question
5

State update using useState is asynchronous in nature.

Question 1 of 5
1  DevCoin image   per question

Coding Questions


Typical Counter App

easy

1  DevCoin image
Merge State in useState

medium

2  DevCoin image
Intro App

easy

1  DevCoin image
opendevs logo
CoursesFAQsContact UsPrivacy PolicyTerms Of Service
Copyright © 2023 opendevs
Learn ● Develop ● Ace
All illustrations by Storyset