Skip to content
Advertisement

How to use redux state data in a link?

I am new to redux and reactjs. I am trying to use a state data called type in the link I am fetching using axios in line no 17. I am setting the value of type from another .jsx file using dispatch().

Here in Home.jsx file I am calling dispatch in line no 24 for updating the state value type with onClick event.

Home.jsx

JavaScript

imageSlice.js

JavaScript

store.js

JavaScript

How to do that? I am trying to update the fetching link using state type value on line 17 in imageSlice.js file.

Advertisement

Answer

One option is to provide the type to fetchImages by parameters (see payload):

JavaScript

Then you need to provide the type to the function, when calling fetchImages. Here in an example component:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement