From 10cbe0d5fcccf477bc6870f89bc3ed040618deb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Thu, 27 Jun 2019 14:30:56 +0800 Subject: [PATCH] bugfix: should use useEffect --- src/layouts/BasicLayout.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/layouts/BasicLayout.tsx b/src/layouts/BasicLayout.tsx index 00a36070..ca57d325 100644 --- a/src/layouts/BasicLayout.tsx +++ b/src/layouts/BasicLayout.tsx @@ -4,19 +4,19 @@ * https://github.com/ant-design/ant-design-pro-layout */ -import { ConnectProps, ConnectState } from '@/models/connect'; import ProLayout, { MenuDataItem, BasicLayoutProps as ProLayoutProps, Settings, } from '@ant-design/pro-layout'; -import React, { useState } from 'react'; - -import Authorized from '@/utils/Authorized'; +import React, { useEffect } from 'react'; import Link from 'umi/link'; -import RightContent from '@/components/GlobalHeader/RightContent'; import { connect } from 'dva'; import { formatMessage } from 'umi-plugin-react/locale'; + +import Authorized from '@/utils/Authorized'; +import RightContent from '@/components/GlobalHeader/RightContent'; +import { ConnectProps, ConnectState } from '@/models/connect'; import { isAntDesignPro } from '@/utils/utils'; import logo from '../assets/logo.svg'; @@ -75,7 +75,7 @@ const BasicLayout: React.FC = props => { * constructor */ - useState(() => { + useEffect(() => { if (dispatch) { dispatch({ type: 'user/fetchCurrent', @@ -84,7 +84,7 @@ const BasicLayout: React.FC = props => { type: 'settings/getSetting', }); } - }); + }, []); /** * init variables -- GitLab