From 43255a2cb5042f91ee690788ec53b1340517d574 Mon Sep 17 00:00:00 2001 From: Jimmy Liow <18777396951@163.com> Date: Wed, 12 Apr 2023 09:22:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9D=83=E9=99=90=E5=92=8C?= =?UTF-8?q?=20useStore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/Auth.js | 11 +++++++++++ src/stores/Root.js | 2 ++ src/views/Plan.jsx | 7 +++---- 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 src/stores/Auth.js diff --git a/src/stores/Auth.js b/src/stores/Auth.js new file mode 100644 index 0000000..3884377 --- /dev/null +++ b/src/stores/Auth.js @@ -0,0 +1,11 @@ +import { makeAutoObservable } from "mobx"; + +class Auth { + + constructor(root) { + makeAutoObservable(this, { rootStore: false }); + this.root = root; + } +} + +export default Auth; \ No newline at end of file diff --git a/src/stores/Root.js b/src/stores/Root.js index f369e8f..fb17968 100644 --- a/src/stores/Root.js +++ b/src/stores/Root.js @@ -1,9 +1,11 @@ import { makeAutoObservable } from "mobx"; import Plan from "./Plan"; +import Auth from "./Auth"; class Root { constructor() { this.plan = new Plan(this); + this.auth = new Auth(this); makeAutoObservable(this); } } diff --git a/src/views/Plan.jsx b/src/views/Plan.jsx index c314b3f..f1e8cf0 100644 --- a/src/views/Plan.jsx +++ b/src/views/Plan.jsx @@ -79,8 +79,7 @@ const data = [ function Plan() { const {planId} = useParams(); - const store = useStore(); - const planStore = store.plan; + const {plan} = useStore(); useEffect(() => { console.info('planId: ' + planId); @@ -94,8 +93,8 @@ function Plan() { - - + +