Skip to content

propNames creating extra property in the JSON #9

@Torniojaws

Description

@Torniojaws

When using this:

         <RIETextArea
            value={ this.state.contents }
            change={ this.editContents }
            propName='contents'
            validate={ _.isString }
            rows={ 10 }
            cols={ 60 }
          />

And then creating the payload to be sent to the API:

  async editContents (updatedText) {
    console.log('Sending updated contents:', updatedText);
    const payload = [{ op: 'replace', path: '/contents', value: updatedText }];

The JSON that is sent out is not as expected.

Expected:

[
  {
    op: "replace",
    path: "/contents",
    value: "The updated text from the textarea element" 
  }
]

Actual:

[
  {
    op: "replace",
    path: "/contents",
    value: {
      contents: "The updated text from the textarea element"
    }
]

If you remove the propName from RIETextArea, it gives an error. Is there some way to strip the { contents: ... } from around the actual data without doing some manual Object.keys() stuff when you want to have multiple fields editable? Of course if there is just one, using eg. updatedText.contents works.

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