【问题标题】:How can I create a context in preact?如何预先创建上下文?
【发布时间】:2019-02-26 08:10:49
【问题描述】:

如何在 preact 中创建上下文?

在反应中喜欢https://reactjs.org/docs/context.html#reactcreatecontext

【问题讨论】:

    标签: preact


    【解决方案1】:

    Preact 支持开箱即用的 legacy context API,但对新的稳定上下文 API 的支持仍在进行中 - 在他们的 GitHub 上打开了一个 pull request 来跟踪这一点。

    与此同时,您可以选择使用旧 API 或使用新 API 的第三方实现,例如 preact-context

    【讨论】:

    • 仅供参考:createContext-API 将包含在我们的下一个主要版本中。 Alpha 版计划于 2019 年 3 月 4 日发布。免责声明:我在 preact 上工作。
    • @marvinhagemeister:太好了,谢谢你的更新:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-30
    • 1970-01-01
    • 2010-11-08
    相关资源
    最近更新 更多