- Remove responsibility for rendering bands from the
BandsContainer
by creatingBands
andBand
components. - Implement a delete button for each band, such that the store is appropriately updated.
Well all things change, and sometimes that means that even our favorite bands break up and we must remove all evidence of them. We want an application that allows us to remove specific bands, and have those changes reflected in our store's state and on the page.
We are starting off with our work from the previous lab, a React/Redux app that
allows us to create new band elements and displays them on the page. In order to
maintain separation of concerns, we have removed the code from BandsContainer
that renders the bands to the page.
The BandInput component is already set up for you and BandsContainer is partially
working, but take a moment to review the flow of information. The BandsContainer
is connected to Redux and has passed the addBand
action to props. addBand
is then passed as props to BandInput
so the action can be dispatched when a new
band is submitted.
-
Create a new
Band
component that will be in charge of displaying the information for a single band. -
Create a new
Bands
component that will handle the rendering of theBand
components from a list of bands provided as props. -
Use
BandsContainer
to access the Redux store using the providedmapStateToProps
method. Pass the bands obtained from the store into theBands
component. -
Currently, bands are stored in state as an array of strings representing the name of each band. In the
manageBand
reducer, change the structure of the state such that each band is an object withid
andname
properties; be sure to assign each band its own unique ID on creation. The array of objects will be available toBandsContainer
throughmapStateToProps
and will need to be passed as props throughBands
to each renderedBand
component. -
In the
Band
component, you will need to add a button that dispatches an action of type'DELETE_BAND'
and passes through that band's id as theaction.id
. This dispatched action should be provided as a prop fromBandsContainer
. -
Finally, you will need to add code to handle the
DELETE_BAND
action in the reducer. When a band's delete button is pressed, it will return a new list of bands that does not include the deleted band.