Skip to content

Adding new components with redux

mike-robertson edited this page Jul 7, 2016 · 1 revision

How to add a new component connected to redux store (high level-ish)

Creating a table?

Copy table definitions (use tableContainerFactory.js factory function, look at Player.jsx for examples), create table columns, and add your request to the page you want (you may need to create a page, look at Peers.jsx or Player.jsx for examples)

copy reducer, change names

Copy an existing reducer. Depending on what data you are getting (array or object), get either gotPlayer/player.js or gotPlayer/matches.js

import into index.js’s and combine reducers that are relevant
copy actions & change names

In the future I will probably have a factory function for these since a lot of them are very similar

actions index changes
copy/change sort and transform selectors

These files are only needed if you are transforming the data (or sorting it, or any other selector is being used)

selectors index changes

Same rules apply as above

add transformations if they are needed

If you are transforming the data, add it to the transformations.js

If I left anything out, I will update this guide. It's only a general idea of what files need to be changed