We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
umi4 model 中使用并导出 query-string 的 parse() 的返回值时,当 model 更新时会出现整个 model 返回值是 undefined 的情况,qs 则不会有这个问题,copy 一下 parse() 返回值再导出,也不会有问题
Please provide a minimal reproduction then upload to your GitHub. 请提供 最小重现,并上传到你的 GitHub 仓库
最小复现:https://github.com/hanzebang/umi4-demo/tree/debug/models/querystring
Steps to reproduce the behavior: 1. 2.
Expected behavior 1. 2.
TypeError: Cannot read properties of undefined (reading 'setState')
useModel
The text was updated successfully, but these errors were encountered:
parse中的返回,是基于 Object.create(null) 生成的对象。
parse
Object.create(null)
https://github.com/sindresorhus/query-string/blob/a5ed7eaf496b47e0cd7f6071a56ac297c8e280e4/index.js#L307
umi中基于 fast-deep-equal 进行前后状态对比
umi
fast-deep-equal
umi/packages/plugins/libs/model.tsx
Lines 162 to 164 in a8487f1
fast-deep-equal 对于 Object.create(null)生成的对象未做兼容,其中调用对象的 valueOf方法报错。导致最后 model拿到的是 undefined。
valueOf
model
undefined
issue: epoberezkin/fast-deep-equal#111
在返回层可以做个兼容
export default () => { const [, setState] = useState<number>(0); const query = parse('?a=1'); return { setState, query: { ...query } }; };
Sorry, something went wrong.
No branches or pull requests
What happens?
umi4 model 中使用并导出 query-string 的 parse() 的返回值时,当 model 更新时会出现整个 model 返回值是 undefined 的情况,qs 则不会有这个问题,copy 一下 parse() 返回值再导出,也不会有问题
Mini Showcase Repository(REQUIRED)
最小复现:https://github.com/hanzebang/umi4-demo/tree/debug/models/querystring
How To Reproduce
Steps to reproduce the behavior: 1. 2.
Expected behavior 1. 2.
TypeError: Cannot read properties of undefined (reading 'setState')
,useModel
的返回值变成 undefined 了Context
The text was updated successfully, but these errors were encountered: