猿问

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里有异常 详见下图

Qyouu
浏览 353回答 1
1回答

PIPIONE

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

相关分类

JavaScript
我要回答