Skip to content

How to get the value typed in the editor into state? #21

@Jimmyelvis

Description

@Jimmyelvis

I have a simple form in my project, with three fields, two regular fields, and one react-trumbowyg field. It seems like I successfully set everything up. I'm not getting any errors in my console. However, I'm not able to get any value typed into the trumbowyg editor into my state.

Here are the relevant bits of code I'm using:

The import statements

import 'react-trumbowyg/dist/trumbowyg.min.css';
import Trumbowyg from 'react-trumbowyg';
import jquery from 'jquery';

The constructor

constructor(props) {
    super(props);
    this.state = {
      text: ""
    };

    this.onChange = this.onChange.bind(this);
    this.onSubmit = this.onSubmit.bind(this);
  }

The onchange event that occurs when a user types into a field

onChange(e) {
    this.setState({ [e.target.name]: e.target.value });
  }

The react-trumbowg component

 <Trumbowyg id='react-trumbowyg'
     placeholder="text"
      name="text"
     value={this.state.text}
      onChange={this.onChange}
        error={errors.text}
    />

Using the chrome Redux tools all I see is just empty quotes after submission for the text field. Am I setting up the actual component right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions