scniro / react-codemirror2

Codemirror integrated components for React
MIT License
1.66k stars 193 forks source link

Warning: UnControlled.shouldComponentUpdate(): Returned undefined instead of a boolean value. Make sure to return true or false. #107

Closed linkenneth closed 6 years ago

linkenneth commented 6 years ago

I'm running unit tests with Jest and ran across a billion warnings like this:

    console.error node_modules/fbjs/lib/warning.js:33
      Warning: UnControlled.shouldComponentUpdate(): Returned undefined instead of a boolean value. Make sure to return true or false.

Any ideas? My usage of react-codemirror2:

import { UnControlled as CodeMirror } from 'react-codemirror2';
import 'codemirror/mode/javascript/javascript';

import 'codemirror/lib/codemirror.css';
import 'codemirror/theme/material.css';

// ...

render() {
    const { code, ...otherProps } = this.props;
    return (
      <div className={cx(this.props.className, styles.main)}>
        <CodeMirror
          editorDidMount={(editor) => this.editor = editor}
          onChange={this.handleChange}
          value={this.state.code}
          {...otherProps}
        />
      </div>
    );
}

Looking at the source code it seems like it should always be returning true or false though. My versions:

package.json:
    "react-codemirror2": "^5.1.0",

package-lock.json
    "react-codemirror2": {
      "version": "5.1.0",
      "resolved": "https://registry.npmjs.org/react-codemirror2/-/react-codemirror2-5.1.0.tgz",
      "integrity": "stuff"
    },
scniro commented 6 years ago

@linkenneth you can see what's returned here - it's always true or false. I don't see any warnings at all with the tests. I'm guessing this is specific to your usage in your app. Going to close this out soon unless the issue is directly related to the lib itself

linkenneth commented 6 years ago

Yes I've seen that too which is why this is so confusing. Thanks! I'll investigate further on my own.