Skip to content

Commit 0cf0765

Browse files
committed
further changes
1 parent ca2532f commit 0cf0765

4 files changed

+51
-7
lines changed

Diff for: hooks-reference.md

+44
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,50 @@ A component calling `useContext` will always re-render when the context value ch
196196
>
197197
>`useContext(MyContext)` only lets you *read* the context and subscribe to its changes. You still need a `<MyContext.Provider>` above in the tree to *provide* the value for this context.
198198
199+
**Putting it together with Context.Provider**
200+
```js{31-36}
201+
const themes = {
202+
light: {
203+
foreground: "#000000",
204+
background: "#eeeeee"
205+
},
206+
dark: {
207+
foreground: "#ffffff",
208+
background: "#222222"
209+
}
210+
};
211+
212+
const ThemeContext = React.createContext(themes.light);
213+
214+
function App() {
215+
return (
216+
<ThemeContext.Provider value={themes.dark}>
217+
<Toolbar />
218+
</ThemeContext.Provider>
219+
);
220+
}
221+
222+
function Toolbar(props) {
223+
return (
224+
<div>
225+
<ThemedButton />
226+
</div>
227+
);
228+
}
229+
230+
function ThemedButton() {
231+
const theme = useContext(ThemeContext);
232+
233+
return (
234+
<button style={{ background: theme.background, color: theme.foreground }}>
235+
I am styled by theme context!
236+
</button>
237+
);
238+
}
239+
```
240+
This example is modified for hooks from a previous example in the [Context Advanced Guide](/docs/context.html), where you can find more information about when and how to use Context.
241+
242+
199243
## Additional Hooks {#additional-hooks}
200244

201245
The following Hooks are either variants of the basic ones from the previous section, or only needed for specific edge cases. Don't stress about learning them up front.

Diff for: lifting-state-up.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ Lifting state involves writing more "boilerplate" code than two-way binding appr
324324

325325
If something can be derived from either props or state, it probably shouldn't be in the state. For example, instead of storing both `celsiusValue` and `fahrenheitValue`, we store just the last edited `temperature` and its `scale`. The value of the other input can always be calculated from them in the `render()` method. This lets us clear or apply rounding to the other field without losing any precision in the user input.
326326

327-
When you see something wrong in the UI, you can use [React Developer Tools](https://github.com/facebook/react-devtools) to inspect the props and move up the tree until you find the component responsible for updating the state. This lets you trace the bugs to their source:
327+
When you see something wrong in the UI, you can use [React Developer Tools](https://github.com/facebook/react/tree/master/packages/react-devtools) to inspect the props and move up the tree until you find the component responsible for updating the state. This lets you trace the bugs to their source:
328328

329329
<img src="../images/docs/react-devtools-state.gif" alt="Monitoring State in React DevTools" max-width="100%" height="100%">
330330

Diff for: reference-javascript-environment-requirements.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
id: javascript-environment-requirements
3-
title: JavaScript Environment Requirements
3+
title: जावास्क्रिप्ट एनवायरनमेंट आवश्यकताएँ
44
layout: docs
55
category: Reference
66
permalink: docs/javascript-environment-requirements.html
77
---
88

9-
React 16 depends on the collection types [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) and [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set). If you support older browsers and devices which may not yet provide these natively (e.g. IE < 11) or which have non-compliant implementations (e.g. IE 11), consider including a global polyfill in your bundled application, such as [core-js](https://github.com/zloirock/core-js) or [babel-polyfill](https://babeljs.io/docs/usage/polyfill/).
9+
React 16 [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) और [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) कलेक्शन टाइप पर निर्भर करता है। यदि आप पुराने ब्राउज़र्स और उपकरणों का समर्थन करते हैं, जो अभी तक ये टाइप नेटिवली प्रदान नहीं कर सकते हैं (जैसे IE <11) या जिनके पास नॉन-कम्प्लाइअन्ट कार्यान्वयन हैं (उदाहरण IE 11), तो अपने बंडल किए गए एप्लिकेशन में एक वैश्विक polyfill शामिल करें, जैसे कि [core-js](https://github.com/zloirock/core-js) या [babel-polyfill](https://babeljs.io/docs/usage/polyfill/)
1010

11-
A polyfilled environment for React 16 using core-js to support older browsers might look like:
11+
पुराने ब्राउज़र्स का समर्थन करने के लिए core-js का उपयोग करके React 16 के लिए एक polyfilled एनवायरनमेंट ऐसा दिखेगा:
1212

1313
```js
1414
import 'core-js/es/map';
@@ -23,8 +23,8 @@ ReactDOM.render(
2323
);
2424
```
2525

26-
React also depends on `requestAnimationFrame` (even in test environments).
27-
You can use the [raf](https://www.npmjs.com/package/raf) package to shim `requestAnimationFrame`:
26+
React `requestAnimationFrame` पर भी निर्भर करती है (परीक्षण एनवायरनमेंट में भी)।
27+
आप `requestAnimationFrame` के समर्थन के लिए [raf](https://www.npmjs.com/package/raf) package का उपयोग कर सकते हैं :
2828

2929
```js
3030
import 'raf/polyfill';

Diff for: reference-react.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ Note that rendering `lazy` components requires that there's a `<React.Suspense>`
333333
334334
### `React.Suspense` {#reactsuspense}
335335
336-
`React.Suspense` let you specify the loading indicator in case some components in the tree below it are not yet ready to render. Today, lazy loading components is the **only** use case supported by `<React.Suspense>`:
336+
`React.Suspense` lets you specify the loading indicator in case some components in the tree below it are not yet ready to render. Today, lazy loading components is the **only** use case supported by `<React.Suspense>`:
337337
338338
```js
339339
// This component is loaded dynamically

0 commit comments

Comments
 (0)