You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-25Lines changed: 12 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,28 +1,15 @@
1
-
# Responsive-Header-Section
2
-
## UseState Hook
3
-
The useState hook is a built-in hook that allows functional components to manage state. It's commonly used when you need to add state to a component without converting it into a class.
4
-
5
-
Here's a basic overview of how to use useState:
6
-
7
-
import React, { useState } from 'react';
8
-
9
-
function ExampleComponent() {<br>
10
-
// Here, we declare a state variable called "count" and a function to update it, "setCount".<br>
11
-
// We initialize the state with a value of 0.<br>
12
-
const [count, setCount] = useState(0);
13
-
14
-
return (
15
-
<div>
16
-
<p>You clicked {count} times</p>
17
-
{/* When the button is clicked, we call setCount to update the state */}<br>
18
-
<button onClick={() => setCount(count + 1)}>
19
-
Click me
20
-
</button>
21
-
</div>
22
-
);
23
-
}
24
-
25
-
export default ExampleComponent;
1
+
# Props
2
+
## 1. Definition
3
+
Props stands for properties and refers to the mechanism for passing data from one component to another within an application.
4
+
5
+
## 2. Here's how it works:
6
+
1. <b>Parent Component Passing Data:</b> A parent component can pass data to a child component by using attributes similar to HTML attributes.
7
+
8
+
2. <b>Receiving Props</b>: The child component receives the data passed by the parent as props. Props are received as an object within the child component.
9
+
10
+
3. <b>Immutable Data</b>: Props are immutable, meaning that a child component cannot directly modify the props it receives from its parent. They are read-only.
11
+
12
+
4. <b>Functional and Class Components</b>: Props can be used with both functional and class components in React.
0 commit comments