nossas / slate-editor

A complete rich text editor based on SlateJS framework
https://slate-editor.bonde.org
MIT License
263 stars 56 forks source link

ESLint and PropTypes #65

Open emipc opened 6 years ago

emipc commented 6 years ago

I'm using ESLint in my project and it was throwing me some errors related to props missing in props validation.

e.g. This is what the original source code looks like for StateEditor.js:

SlateEditor.propTypes = {
  initialState: PropTypes.object
}

And I've added the missing props like these ones:

SlateEditor.propTypes = {
    initialState: PropTypes.object,
    onChange: PropTypes.func.isRequired,
    plugins: PropTypes.array,
    children: PropTypes.node.isRequired,
};

SlateEditor.defaultProps = {
    plugins: [],
    initialState: undefined
};

Nevertheless, I'm getting this warning:

Warning: Failed prop type: The prop onChange is marked as required in SlateEditor, but its value is undefined.

I've added a console.log to ensure onChange exists and it does.

Do you know why it's throwing me this warning?