The goal is to get to send an object from my form to my action. (no async)
I keep getting "Actions must be plain objects. Use custom middleware for async actions."
I have my action like this (I can console.log the productType and product,the data is coming to my action but I keep getting the console error mentioned above):
export function addProduct(productType, product) {
switch (productType) {
case 'survey':
return {
type: actions.ADD_SURVEY,
payload: product,
}
case 'reward':
return {
type: actions.ADD_REWARD,
payload: product,
}
default:
return null
}
}
In my component, I'm calling my action (data is the object from my form):
import { useDispatch } from 'react-redux'
const dispatch = useDispatch()
function onSubmit(data) {
const productType = 'reward'
dispatch(addProductAction({ productType, data }))
}