From 29379c6fe3864b415933ac7a83bdeb22823a719b Mon Sep 17 00:00:00 2001 From: Jason Liang Date: Mon, 19 Aug 2024 10:03:33 +0800 Subject: [PATCH] content(react): fix react context#247 --- .../5-\344\270\212\344\270\213\346\226\207/react/App.jsx" | 5 ++--- .../react/UserContext.jsx" | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 "content/4-\347\273\204\344\273\266\347\273\204\345\220\210/5-\344\270\212\344\270\213\346\226\207/react/UserContext.jsx" diff --git "a/content/4-\347\273\204\344\273\266\347\273\204\345\220\210/5-\344\270\212\344\270\213\346\226\207/react/App.jsx" "b/content/4-\347\273\204\344\273\266\347\273\204\345\220\210/5-\344\270\212\344\270\213\346\226\207/react/App.jsx" index 06291a26..91f4554f 100644 --- "a/content/4-\347\273\204\344\273\266\347\273\204\345\220\210/5-\344\270\212\344\270\213\346\226\207/react/App.jsx" +++ "b/content/4-\347\273\204\344\273\266\347\273\204\345\220\210/5-\344\270\212\344\270\213\346\226\207/react/App.jsx" @@ -1,7 +1,6 @@ -import { useState, createContext } from "react"; +import { useState } from "react"; import UserProfile from "./UserProfile"; - -export const UserContext = createContext(); +import { UserContext } from "./UserContext"; export default function App() { // 在实际项目,你会从接口获取用户数据 diff --git "a/content/4-\347\273\204\344\273\266\347\273\204\345\220\210/5-\344\270\212\344\270\213\346\226\207/react/UserContext.jsx" "b/content/4-\347\273\204\344\273\266\347\273\204\345\220\210/5-\344\270\212\344\270\213\346\226\207/react/UserContext.jsx" new file mode 100644 index 00000000..c5d5d2e5 --- /dev/null +++ "b/content/4-\347\273\204\344\273\266\347\273\204\345\220\210/5-\344\270\212\344\270\213\346\226\207/react/UserContext.jsx" @@ -0,0 +1,3 @@ +import { createContext } from "react"; + +export const UserContext = createContext();