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.
When using this:
And then creating the payload to be sent to the API:
The JSON that is sent out is not as expected.
Expected:
Actual:
If you remove the
propNamefrom RIETextArea, it gives an error. Is there some way to strip the{ contents: ... }from around the actual data without doing some manualObject.keys()stuff when you want to have multiple fields editable? Of course if there is just one, using eg.updatedText.contentsworks.