Skip to content

Commit e3b368a

Browse files
merging all conflicts
2 parents 5a263fd + 2639f36 commit e3b368a

14 files changed

Lines changed: 1084 additions & 138 deletions

File tree

-38.5 KB
Binary file not shown.
76.5 KB
Loading
463 KB
Loading
-245 KB
Binary file not shown.
10.8 KB
Loading

src/components/ButtonLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function ButtonLink({
3333
className,
3434
'active:scale-[.98] transition-transform inline-flex font-bold items-center outline-none focus:outline-none focus-visible:outline focus-visible:outline-link focus:outline-offset-2 focus-visible:dark:focus:outline-link-dark leading-snug',
3535
{
36-
'bg-link text-white dark:bg-brand-dark dark:text-secondary hover:bg-opacity-80':
36+
'bg-link text-white dark:bg-brand-dark dark:text-gray-90 hover:bg-opacity-80':
3737
type === 'primary',
3838
'text-primary dark:text-primary-dark shadow-secondary-button-stroke dark:shadow-secondary-button-stroke-dark hover:bg-gray-40/5 active:bg-gray-40/10 hover:dark:bg-gray-60/5 active:dark:bg-gray-60/10':
3939
type === 'secondary',

src/content/learn/tutorial-tic-tac-toe.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,19 +907,34 @@ body {
907907
908908
### أدوات مطور React (React DevTools) {/*react-developer-tools*/}
909909
910+
<<<<<<< HEAD
910911
أدوات مطور React تتيح لك التحقق من الخصائص والحالة لمكونات React الخاصة بك. يمكنك العثور على علامة تبويب أدوات مطوري React في أسفل قسم المتصفح في CodeSandbox:
911912
912913
![أدوات مطوري React في CodeSandbox](../images/tutorial/codesandbox-devtools.png)
913914
914915
لفحص مكون معين على الشاشة، استخدم الزر في الزاوية اليسرى العليا من أدوات مطوري React:
915916
916917
![تحديد مكونات في الصفحة من أدوات مطوري React](../images/tutorial/devtools-select.gif)
918+
=======
919+
React Developer Tools let you check the props and the state of your React components. It is available as a [Chrome](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en), [Firefox](https://addons.mozilla.org/en-US/firefox/addon/react-devtools/), and [Edge](https://microsoftedge.microsoft.com/addons/detail/react-developer-tools/gpphkfbcpidddadnkolkpfckpihlkkil) browser extension.
917920
918-
<Note>
921+
After you install it, a new *Components* tab will appear in your browser Developer Tools for sites using React. If you're following along in CodeSandbox, you'd need to first open your sandbox preview in a new tab:
922+
923+
![opening in new tab](../images/tutorial/sandbox-new-tab.png)
924+
925+
Then, on the preview page, open your browser's DevTools and find the *Components* tab:
926+
>>>>>>> 2639f369946f763fff9a2572b0d7c4b9e2f83ebd
919927
928+
![components tab](../images/tutorial/components-tab.png)
929+
930+
<<<<<<< HEAD
920931
إن كنت تستخدم بيئة التطوير المحلية، أدوات مطوري React متوفرة كإضافة لمتصفحات [Chrome](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=ar)، [Firefox](https://addons.mozilla.org/ar/firefox/addon/react-devtools/)، و [Edge](https://microsoftedge.microsoft.com/addons/detail/react-developer-tools/gpphkfbcpidddadnkolkpfckpihlkkil). قم بتثبيتها، وستظهر علامة التبويب *Components* في أدوات المطور لمتصفحك للمواقع التي تستخدم React.
932+
=======
933+
To inspect a particular component on the screen, use the button in the top left corner of the Components tab:
934+
935+
![inspecting with devtools](../images/tutorial/devtools-inspect.gif)
936+
>>>>>>> 2639f369946f763fff9a2572b0d7c4b9e2f83ebd
921937
922-
</Note>
923938
924939
## إكمال اللعبة {/*completing-the-game*/}
925940

src/content/reference/react-dom/components/form.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,47 @@ To create interactive controls for submitting information, render the [built-in
4848

4949
## Usage {/*usage*/}
5050

51-
### Handle form submission on the client {/*handle-form-submission-on-the-client*/}
51+
### Handle form submission with an event handler {/*handle-form-submission-with-an-event-handler*/}
5252

53-
Pass a function to the `action` prop of form to run the function when the form is submitted. [`formData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) will be passed to the function as an argument so you can access the data submitted by the form. This differs from the conventional [HTML action](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#action), which only accepts URLs. After the `action` function succeeds, all uncontrolled field elements in the form are reset.
53+
Pass a function to the `onSubmit` event handler to run code when the form is submitted. By default, the browser sends the form data to the current URL and refreshes the page, so call [`e.preventDefault()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault) to override that behavior.
54+
55+
This example reads the submitted values with [`new FormData(e.target)`](https://developer.mozilla.org/en-US/docs/Web/API/FormData), which collects every field by its `name`. This keeps the inputs [uncontrolled](/reference/react-dom/components/input#reading-the-input-values-when-submitting-a-form). If you instead [control an input with state](/reference/react-dom/components/input#controlling-an-input-with-a-state-variable), read from that state on submit rather than from `FormData`.
56+
57+
<Sandpack>
58+
59+
```js src/App.js
60+
export default function Search() {
61+
function handleSubmit(e) {
62+
// Prevent the browser from reloading the page
63+
e.preventDefault();
64+
65+
// Read the form data
66+
const form = e.target;
67+
const formData = new FormData(form);
68+
const query = formData.get("query");
69+
alert(`You searched for '${query}'`);
70+
}
71+
72+
return (
73+
<form onSubmit={handleSubmit}>
74+
<input name="query" />
75+
<button type="submit">Search</button>
76+
</form>
77+
);
78+
}
79+
```
80+
81+
</Sandpack>
82+
83+
<Note>
84+
85+
Reading form data with `onSubmit` works in every version of React and gives you direct access to the [submit event](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit_event), so you can call `e.preventDefault()` and read the data yourself. Passing the function to the `action` prop instead runs the submission in a [Transition](/reference/react/useTransition). React then tracks the pending state, sends thrown errors to the nearest error boundary, and lets the form work with [`useActionState`](/reference/react/useActionState) and [`useOptimistic`](/reference/react/useOptimistic). An `action` can also be a [Server Function](/reference/rsc/server-functions), which `onSubmit` does not support.
86+
87+
</Note>
88+
89+
### Handle form submission with an action prop {/*handle-form-submission-with-an-action-prop*/}
90+
91+
Pass a function to the `action` prop of form to run the function when the form is submitted. [`formData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) will be passed to the function as an argument so you can access the data submitted by the form. This differs from the conventional [HTML action](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#action), which only accepts URLs. Unlike `onSubmit`, an `action` runs in a [Transition](/reference/react/useTransition) and calling `e.preventDefault()` isn't needed. After the `action` function succeeds, all uncontrolled field elements in the form are reset.
5492

5593
<Sandpack>
5694

src/content/reference/react/Component.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ Deriving state leads to verbose code and makes your components difficult to thin
10091009
10101010
#### Caveats {/*static-getderivedstatefromprops-caveats*/}
10111011
1012-
- This method is fired on *every* render, regardless of the cause. This is different from [`UNSAFE_componentWillReceiveProps`](#unsafe_cmoponentwillreceiveprops), which only fires when the parent causes a re-render and not as a result of a local `setState`.
1012+
- This method is fired on *every* render, regardless of the cause. This is different from [`UNSAFE_componentWillReceiveProps`](#unsafe_componentwillreceiveprops), which only fires when the parent causes a re-render and not as a result of a local `setState`.
10131013
10141014
- This method doesn't have access to the component instance. If you'd like, you can reuse some code between `static getDerivedStateFromProps` and the other class methods by extracting pure functions of the component props and state outside the class definition.
10151015

0 commit comments

Comments
 (0)