Function useDispatch

  • Gets the dispatch function from the Redux store in context.

    Returns (action: UnknownAction) => void

    Dispatch function that can be called with a Redux action.

    <script>
    import { useDispatch } from "@laserware/sword";

    import { someAction } from "./my-redux-actions";

    const dispatch = useDispatch();

    function handleClick() {
    dispatch(someAction());
    }
    </script>

    <button onclick={handleClick}>Click Me</button>