scniro / react-codemirror2

Codemirror integrated components for React
MIT License
1.65k stars 192 forks source link

When no onChange handler, component throws error #68

Closed miuirussia closed 6 years ago

miuirussia commented 6 years ago
TypeError: _this.props.onChange is not a function. (In '_this.props.onChange(_this.editor, data, _this.editor.getValue())', '_this.props.onChange' is undefined)

Probably due to lack of verification: https://github.com/scniro/react-codemirror2/blob/a78ade3804bb922d2c407051218d19ec93b7650c/src/index.tsx#L680-L687

scniro commented 6 years ago

@miuirussia yea this looks like an issue. I can add a check for it. You should just add an onChange for now...

scniro commented 6 years ago

@miuirussia fixed with 4.2.1