Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.
This repository was archived by the owner on Oct 13, 2021. It is now read-only.

使用antd的TabBar的Tips #4

@shujer

Description

@shujer

之前使用了TabBar写了一个高阶组件,将页面传入作为渲染内容。后面遇到了一系列的Bug,比如:①componentWillReceiveProps和 render重复执行;② state状态无法改变。找了很久才发现是因为使用了TabBar,组件重新渲染了,导致一系列操作重复执行(包括componentWillReceiveProps中进行的网络请求),这显然不是我们想要的。因此,重新改进布局组件,如下:
https://github.com/SusieChang/react-app/blob/d71fa3389e81a9613c3406918bbc47fc54aef47a/src/layouts/withTabBarBasicLayout/index.js#L36-L52

  • 设置noRenderContent={true}
  • <WrappedComponent {...props} />提升到外面容器

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions