react 高阶组件(HOC)返回的组件在react-developer tools 显示

const withLoading = Component => ({ isLoading, ...rest }) =>

    isLoading ? <Loading /> : <Component { ...rest } />

const ButtonWithLoading = withLoading(Button)

render里:


<ButtonWithLoading isLoading={false}>

    More

</ButtonWithLoading>

结果:页面展示效果正常 但tools里有异常 详见下图

https://img.mukewang.com/5c8f092c0001172d08000264.jpg

Qyouu
浏览 353回答 1
1回答

PIPIONE

你返回的是个匿名Stateless Component试一下const withLoading = Component => function CustomComp({ isLoading, ...rest }) {&nbsp; return isLoading ? <Loading /> : <Component { ...rest } />}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript