【问题标题】:Mutate state based on existing fields根据现有字段改变状态
【发布时间】:2018-06-25 15:00:05
【问题描述】:

使用 React-Final-Form,我正在创建一个控件,如果单击单选按钮,则允许用户在目录中列出。在点击处理程序中,我希望使用用户的名字和姓氏自动填充一个文本框。我正在使用 mutator 执行此操作,我希望能够确认我正在正确执行此操作,因为我找不到有关我正在利用的 lastFieldState 属性的文档:

  setDisplayName: (args, state, utils) => {
  const { firstname, lastname } = state.fields;
  const currentFirstName = firstname.lastFieldState.value;
  const currentLastName = lastname.lastFieldState.value;
  utils.changeValue(state, 'displayName', () => `${currentFirstName} ${currentLastName}`);
},

【问题讨论】:

    标签: react-final-form final-form


    【解决方案1】:

    这里是图书馆的作者。我可以确认你做得很好。 ?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-15
      • 2020-12-16
      • 2021-05-28
      • 1970-01-01
      • 2018-03-30
      • 2019-04-29
      • 2021-12-24
      相关资源
      最近更新 更多