From 371e1d6f4b4d6796bb92967ee15650a612a01d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?chencheng=20=28=E4=BA=91=E8=B0=A6=29?= Date: Wed, 11 Dec 2019 12:25:09 +0800 Subject: [PATCH] fix: lodash -> lodash.isequal (#14) * fix: lodash -> lodash.isequal * update --- src/helpers/isEqual.ts | 2 -- src/utils/getUseModelContent.ts | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) delete mode 100644 src/helpers/isEqual.ts diff --git a/src/helpers/isEqual.ts b/src/helpers/isEqual.ts deleted file mode 100644 index c518e76..0000000 --- a/src/helpers/isEqual.ts +++ /dev/null @@ -1,2 +0,0 @@ -// @ts-ignore -export { default as isEqual } from 'lodash.isequal'; \ No newline at end of file diff --git a/src/utils/getUseModelContent.ts b/src/utils/getUseModelContent.ts index 9a23a67..b15dde5 100644 --- a/src/utils/getUseModelContent.ts +++ b/src/utils/getUseModelContent.ts @@ -2,9 +2,9 @@ import { join } from 'path'; export default function() { return `import { useState, useEffect, useContext, useRef } from 'react'; +import isEqual from '${require.resolve('lodash.isequal')}'; import { UmiContext } from '${join(__dirname, '..', 'helpers', 'constant')}'; import { Model } from './provider'; -import { isEqual } from 'lodash'; export function useModel>(model: T): Model[T] export function useModel, U>(model: T, selector: (model: Model[T]) => U): U @@ -42,7 +42,8 @@ export function useModel, U>( return () => { dispatcher.callbacks![namespace]!.delete(handler); } - }, [namespace]) + }, [namespace]); + return state; }; `;