小编Doe*_*Doe的帖子

Dispatch 不是一个函数 react

我正在使用 react 和 redux 开发一个应用程序。我使用api。

申请流程:

  • 填表格,
  • 点击发送按钮,
  • 将数据从表单发送到 api,
  • 转到食谱页面

第一个组成部分是您输入信息的表格(姓名、卡路里、饮食类型)。

    class FormPage extends Component {
      constructor(props) {
        super(props);

        this.handleFormSubmit = this.handleFormSubmit.bind(this);
        this.goToListOfMealPage = this.goToListOfMealPage.bind(this);
      }

      handleFormSubmit(data) {
        const name = data.name;
        const calories = data.caloreis;
        const diet = data.diet;
        const health = data.health;

        console.log(name)
        return loadData( name, calories, diet, health)()
          .then(({ error }) => {
            if (!error) {
              setTimeout(this.goToListOfMealPage, 1500);
            }

            return error;
          }
        );
      }

      goToListOfMealPage() {
        const { history } = this.props;
        history.push('/ListMeal');
      }

      render() { …
Run Code Online (Sandbox Code Playgroud)

reactjs redux react-redux

0
推荐指数
1
解决办法
660
查看次数

标签 统计

react-redux ×1

reactjs ×1

redux ×1