如何使用redux钩子添加新值来存储?

时间:2019-10-03 00:57:16

标签: reactjs react-redux

这是我的代码

import React from "react";
import { useDispatch, useSelector } from "react-redux";

export function ExampleComponent() {
  const { counter } = useSelector(state => ({
    counter: state.reducer2.counter
  }));
  const dispatch = useDispatch();
  return (
    <div>
        <button onClick={() => dispatch({ type: "INCREMENT" })}>
          INCREMENT
        </button>
    </div>
  );
}

我是redux的新手。 如何使用redux钩子添加新值来存储? 假设当我单击INCREMENT按钮时,会将新行添加到商店中。

0 个答案:

没有答案