I have a syntax question about the connect function in Redux. I’m getting pretty comfortable using it and I understand conceptually what it is accomplishing, which is connecting Redux to the React component you are applying it to. Specifically, providing the component access to the pieces of state you want it to be able to access and giving it access to action creators as callbacks it can call. This all becomes available in the component’s props.
However, what is the syntax used to accomplish this? I’m really unfamiliar with this:
connect()(TodoApp)
or
connect(state => state)(TodoApp)
where you are just wrapping the component in parentheses after calling connect. I’ve also seen this syntax:
@connect(
state => ({ state: state.appState }),
actions => ({ actions: bindActionCreators(actions, dispatch) })
)
class App extends React.Component {
render() {
return (
<div> App </div>
)
}
}
export default App
Although I’ve been writing this I’ve got no clue how what this syntax is/represents in JavaScript.