From 7f5205c74bad7c49b6269f3604c8e246eee188d3 Mon Sep 17 00:00:00 2001 From: YuJian Date: Tue, 29 Mar 2022 15:44:34 +0800 Subject: [PATCH] vault backup: 2022-03-29 15:44:34 --- .obsidian/workspace | 6 +++--- 随时随地/简单的 React 思考 - Context.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.obsidian/workspace b/.obsidian/workspace index 7f881d0..225513c 100644 --- a/.obsidian/workspace +++ b/.obsidian/workspace @@ -9,7 +9,7 @@ "state": { "type": "markdown", "state": { - "file": "随时随地/简单的 React 思考 - Fiber 创建.md", + "file": "随时随地/简单的 React 思考 - Context.md", "mode": "source", "source": false } @@ -69,7 +69,7 @@ "state": { "type": "backlink", "state": { - "file": "随时随地/简单的 React 思考 - Fiber 创建.md", + "file": "随时随地/简单的 React 思考 - Context.md", "collapseAll": false, "extraContext": false, "sortOrder": "alphabetical", @@ -89,8 +89,8 @@ }, "active": "1508f46ea2481b37", "lastOpenFiles": [ - "随时随地/简单的 React 思考 - Fiber 创建.md", "随时随地/简单的 React 思考 - Context.md", + "随时随地/简单的 React 思考 - Fiber 创建.md", "基于 React Hook 开发的 Jira 系统/React 状态管理工具的简单思考.md", "随时随地/简单的 React 思考 - Hook.md", "随时随地/React Hooks 的碎片记录.md", diff --git a/随时随地/简单的 React 思考 - Context.md b/随时随地/简单的 React 思考 - Context.md index 59c3209..52c891f 100644 --- a/随时随地/简单的 React 思考 - Context.md +++ b/随时随地/简单的 React 思考 - Context.md @@ -4,7 +4,7 @@ ### React.createContext ```javascript -const MyContext = React.createContext(default) +const MyContext = React.createContext(defaultValue) ``` -createContext 会创建一个 \ No newline at end of file +createContext 会创建一个 Context 对象,订阅了这个 Context 会在组件树中查找离自己最近的 Provider 中读取到 Context 值,只有在找不到 \ No newline at end of file