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

propNames creating extra property in the JSON #9

Open
Torniojaws opened this issue Dec 2, 2018 · 0 comments
Open

propNames creating extra property in the JSON #9

Torniojaws opened this issue Dec 2, 2018 · 0 comments

Comments

@Torniojaws
Copy link

Torniojaws commented Dec 2, 2018

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.

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

1 participant