M
M
Mr_NoMore2020-06-22 12:39:04
React
Mr_NoMore, 2020-06-22 12:39:04

UseSelector after doing redux action?

I execute a post request, write the response to state. After executing the request, you need to get the data in the react component.

const response = useSelector(state => state.products)

    const handleSave = useCallback(async (productData, formData) => {
        await dispatch(productActions.createProduct(productData))
        response && await sendData(formData, response.data) // вот тут мне нужны данные c респонса
    }, [])


It turns out that I am executing a post request, in the next function I need the data that comes from the rispons.
Now the action is being dispatched -> the sendData function is called and after that I get the necessary data into the response variable, but I need to get the data from the response before calling the sendData function.
How to do it right?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question