【问题标题】:Is it possible to change the displayName of a Context.Consumer?是否可以更改 Context.Consumer 的显示名称?
【发布时间】:2018-10-12 20:05:10
【问题描述】:

我怎样才能找到解决嵌套上下文的方法并避免这个地狱?

【问题讨论】:

标签: reactjs react-context react-16


【解决方案1】:

这有效(至少在 React v16.3.0+ 上):

SomeContext.Consumer.displayName = "SomeContext.Consumer";
SomeContext.Provider.displayName = "SomeContext.Provider";

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-29
    • 2012-07-03
    • 2016-08-28
    • 2019-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多