'send function to redux

so I have a component that will render when I want to get confirmation on some action from user, like 'delete a resource'. This component, expects a onConfirm prop (from redux) which is a (redux action)

 const Confirm = () => {

    const {onConfirm, open} = useSelector (state => state.confirm);

    const handleConfirm = () => {
        dispatch (onConfirm?.());
    };
    return some jsx....
}

and I trigger like this

 <button onClick= dispatch (openConfirmbox({
      onConfirm   : deleteStuff //a redux action,
       ....
 })),>

But I've heard it's not a good practice to put functions in redux store (although it works)

Do you have any other solution?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source