We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 88c2ae2 commit 806e260Copy full SHA for 806e260
src/exercises-final/02.extra-1.js
@@ -8,7 +8,7 @@ function Toggle({children}) {
8
const [on, setOn] = React.useState(false)
9
const toggle = () => setOn(!on)
10
return React.Children.map(children, child => {
11
- return typeof child === 'string'
+ return typeof child.type === 'string'
12
? child
13
: React.cloneElement(child, {on, toggle})
14
})
src/exercises/01.js
@@ -30,7 +30,7 @@ function UserProvider({children}) {
30
// which retrieves the context value via React.useContext, then people can use
31
// your custom hook. If you want to try that, then go ahead and put it here.
32
33
-// This is a utility function which accepts the reduer's dispatch function
+// This is a utility function which accepts the reducer's dispatch function
34
// as well as the user and any updates. It's responsible for interacting with
35
// the userClient and the dispatch.
36
async function updateUser(dispatch, user, updates) {
src/exercises/03.js
@@ -22,13 +22,15 @@ function Toggle({onToggle, children}) {
22
// 🐨 we'll still get the children from props (as it's passed to us by the
23
// developers using our component), but we'll get `on` implicitely from
24
// ToggleContext now
25
+// 🦉 You can create a helper method to retrieve the context here. Thanks to that,
26
+// your context won't be exposed to the user
27
// 💰 `const context = useContext(ToggleContext)`
28
// 📜 https://reactjs.org/docs/hooks-reference.html#usecontext
29
function ToggleOn({on, children}) {
return on ? children : null
}
-// 🐨 do the same thing to this that you did to the On component
+// 🐨 do the same thing to this that you did to the ToggleOn component
function ToggleOff({on, children}) {
return on ? null : children
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments