【问题标题】:Integrating react-redux, react-final-form and react-bootstrap-typeahead集成 react-redux、react-final-form 和 react-bootstrap-typeahead
【发布时间】:2018-04-30 15:59:33
【问题描述】:

我正在尝试设置react-boostrap-typeahead 以从redux 存储中获取数据,并将预输入状态与react-final-form 一起存储。 问题是react-bootstrap-typeahead 附加了多个状态,这两个状态都需要跟踪才能使此设置正常工作。

  1. 文本输入状态
  2. 选择的选项

我首选的解决此问题的方法涉及final-form-set-field-data,如下所示: https://codesandbox.io/s/rl81o5765o

该代码将无法正常工作,因为Form 组件不知道字段数据的更改。 有没有更好的方法来解决这个问题?

【问题讨论】:

    标签: reactjs react-redux react-final-form final-form react-bootstrap-typeahead


    【解决方案1】:

    我在这里想出了一个解决方案:

    https://codesandbox.io/s/5m4w2909k

    方法是引入一个withKeyword HoC,它利用final-form-set-field-data 向该字段注入keywordupdateKeyword 属性。 Typeahead 必须单独连接到 redux 存储。

    【讨论】:

    • 我现在面临着类似的问题。我需要 React-Select + React Final Form。我试图举出你的例子,但给了我:在“Connect(GithubUserTypeahead)”的上下文或道具中找不到“商店”。要么将根组件包装在 中,要么将“store”作为道具显式传递给“Connect(GithubUserTypeahead)”。
    猜你喜欢
    • 2021-04-15
    • 2020-01-24
    • 1970-01-01
    • 1970-01-01
    • 2021-07-29
    • 1970-01-01
    • 1970-01-01
    • 2018-09-19
    • 1970-01-01
    相关资源
    最近更新 更多