Yansen 2 年 前
コミット
319ca9f95b
共有3 個のファイルを変更した7 個の追加4 個の削除を含む
  1. 3
    1
      src/layouts/hooks/useShow.js
  2. 2
    1
      src/layouts/index.jsx
  3. 2
    2
      src/store/page.js

+ 3
- 1
src/layouts/hooks/useShow.js ファイルの表示

@@ -9,7 +9,9 @@ export default (fn, deps = []) => {
9 9
   fnRef.current = fn;
10 10
 
11 11
   const { getPageCtx } = useModel('page');
12
-  const { show } = React.useContext(getPageCtx());
12
+  // eslint-disable-next-line react-hooks/exhaustive-deps
13
+  const ctx = React.useMemo(getPageCtx, []);
14
+  const { show } = React.useContext(ctx);
13 15
 
14 16
   React.useEffect(() => {
15 17
     if (show) {

+ 2
- 1
src/layouts/index.jsx ファイルの表示

@@ -15,10 +15,11 @@ export default (props) => {
15 15
   const { setPageCtx } = useModel('page');
16 16
   const [pageShow, setPageShow] = React.useState(false);
17 17
   const PageContext = React.useMemo(() => {
18
-    const ctx = React.createContext();
18
+    const ctx = React.createContext({show: false});
19 19
     setPageCtx(ctx);
20 20
 
21 21
     return ctx;
22
+  // eslint-disable-next-line react-hooks/exhaustive-deps
22 23
   }, []);
23 24
 
24 25
   const containerClass = `${laySty['page-conatiner']} ${tabBar ? laySty['with-tabbar'] : ''} ${className}`;

+ 2
- 2
src/store/page.js ファイルの表示

@@ -3,8 +3,8 @@ import React from "react";
3 3
 export default () => {
4 4
   const pageCtxRef = React.useRef();
5 5
 
6
-  const setPageCtx = (pg) => {
7
-    pageCtxRef.current = pg;
6
+  const setPageCtx = (ctx) => {
7
+    pageCtxRef.current = ctx;
8 8
   }
9 9
   const getPageCtx = () => {
10 10
     return pageCtxRef.current;