Skip to content
Advertisement

Creating table with data from API using Redux

I’m attempting to get information about NBA teams using Redux, then put that data into a table. Right now I’m able to get the data from the API, but I’m struggling to figure out the correct syntax to display a table with the data I collect using Redux (I usually use getContext and am trying to familiarize myself with Redux more).

This is my App.js

JavaScript

This is my store.js

JavaScript

And this is teamsSlice.js

JavaScript

I haven’t yet created the actual table, I’m just trying to get the syntax correct for being able to click a button and return a table based on data from the store.

Could anyone tell me what I’m doing wrong?

Advertisement

Answer

Since you are using redux and your request is not in the file it is important to keep an eye on changes to the object you need the information for, this is one way to do it:

JavaScript

with this, when the effect detects a change in that object it will put it in the state when it exists

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