Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using react-rte with formsy. #24

Closed
nixypanda opened this issue Apr 2, 2016 · 1 comment
Closed

Using react-rte with formsy. #24

nixypanda opened this issue Apr 2, 2016 · 1 comment

Comments

@nixypanda
Copy link

How to use this component with formsy-react? Here is how I tried it.

...
class FormsyRichTextEditor extends React.Component {

  state = {
    value: RichTextEditor.createEmptyValue()
  };

  static propTypes = {
     ...
  }

  __handleChange__ = (value) => {
    this.setState({ value });
    this.props.setValue(value.toString('markdown'));
  }

  render() {
    let className = ' ';
    className += this.props.showRequired() ? 'required' : '';
    className += this.props.showError() ? 'error' : '';

    let errorMessage = this.props.getErrorMessage();

    return (
      <div className={'text-left form-group' + className }>
        <label htmlFor={this.props.id}>{this.props.title}</label>
        <RichTextEditor
          id={this.props.id}
          name={this.props.name}
          value={this.state.value}
          onChange={this.__handleChange__} />
        <span className='error-message'>{errorMessage}</span>
      </div>
    );
  }
}

export default HOC(FormsyRichTextEditor);

I get the following issue

Warning: A component is `contentEditable` and contains `children` managed by React. It is now your responsibility to guarantee that none of those nodes are unexpectedly modified or duplicated. This is probably not intentional.

Some digging into the issue shows people creating rte are facing this issue and there is a way to suppress this warning. Is there any way to suppress it with react-rte?
Really unsure as to what this warning means and why it is there?

@sstur
Copy link
Owner

sstur commented Apr 2, 2016

Your code looks good. That warning you're seeing is harmless. It's actually a legacy warning built-in to React. You have a two choices if you want to get rid of it:

  • Upgrade to React 0.15 (It's not a final release, it's release candidate v15.0.0-rc.2)
  • Shim console object to filter out this warning. I've used this with some success:
console.error = (function(_error) {
  return function(message) {
    if (typeof message !== 'string' || message.indexOf('component is `contentEditable`') === -1) {
      _error.apply(console, arguments);
    }
  };
})(console.error);

@sstur sstur closed this as completed Apr 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants