Skip to content

Commit

Permalink
Fix #11, using bindActionCreators
Browse files Browse the repository at this point in the history
  • Loading branch information
remo5000 committed May 17, 2018
1 parent d4f587c commit b2a2aa8
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/containers/EditorContainer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { connect, MapDispatchToProps, MapStateToProps } from 'react-redux'
import { Dispatch } from 'redux'
import { bindActionCreators, Dispatch } from 'redux'

import { evalEditor, updateEditorValue } from '../actions/playground'
import Editor, { IEditorProps } from '../components/Editor'
Expand All @@ -22,11 +22,13 @@ const mapStateToProps: MapStateToProps<StateProps, {}, IState> = state => {
* `updateEditorValue` with `newCode`, the updated contents of the react-ace
* editor.
*/
const mapDispatchToProps: MapDispatchToProps<DispatchProps, {}> = (dispatch: Dispatch<any>) => {
return {
handleEditorChange: (newCode: string) => dispatch(updateEditorValue(newCode)),
handleEvalEditor: () => dispatch(evalEditor())
}
}
const mapDispatchToProps: MapDispatchToProps<DispatchProps, {}> = (dispatch: Dispatch<any>) =>
bindActionCreators(
{
handleEditorChange: updateEditorValue,
handleEvalEditor: evalEditor
},
dispatch
)

export default connect(mapStateToProps, mapDispatchToProps)(Editor)

0 comments on commit b2a2aa8

Please sign in to comment.