I started learning Redux and the whole idea looks neat, but after rebuilding my React app from "normal" to "redux-way" this problem came up.
I have a list of if items that I build based on JSON from async call. Then every item on that list sends an async call on click and returns something.
Before my app was pretty straightforward:
components/list/List.jsx
components/list/ListItem.jsx
Right now it looks like this:
footer/list/ListContainer.jsx // here I run an async call and generate list
footer/list/List.jsx // dumb component creating the whole list full of ListItemContainer components as <li>
footer/list/ListItemContainer.jsx // here I run another async for each <li>
footer/list/ListItem.jsx // dumb component containing <li>
It's much more complicated IMO, but there's another problem.
Every time I click on my <li>
component I want to trigger an action and then do something, my question is: can I do that in ListItem.jsx? I don't think so, because it's a dumb component?
Here's my ListItem.jsx right now:
import React from 'react';
import { connect } from 'react-redux';
// some other imports
class ListItem extends React.Component {
render(props) {
return (
<li>
<a href="#" onClick={//can I do something here?//}>
{this.props.contents}
</a>
</li>
)
}
}
export default ListItem;