question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Got the error "value must be string"

See original GitHub issue

I dit this function:

function Wysiwyg() {
  const editor = React.useRef(null)
  const [content, setContent] = React.useState('')
  const config = {
    readonly: false, // all options from https://xdsoft.net/jodit/doc/
  }

  return (
    <JoditEditor
      ref={editor}
      value={content}
      config={config}
      // eslint-disable-next-line
      tabIndex={1} // tabIndex of textarea
      onBlur={(newContent) => setContent(newContent)}
      onChange={() => {}}
    />
  )
}

But when I click on the are I get an error message “value must be string”. I use React 16.13

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:10

github_iconTop GitHub Comments

6reactions
kirkrdcommented, Dec 3, 2020

OnBlur currently return a FocusEvent and not a string value. Which is why the error occurs. I managed to get the value by creating a OnBlur handler like this:

const onBlur = (event: any) => { const editorValue = event.target.innerHTML; setContent(editorValue); };

Then props: OnBlur={onBlur}

Workaround, but either the docs/types should be updated or make the return value a string value again.

1reaction
cheshirrrcatcommented, Feb 12, 2021

Hi guys! I dealt with this problem like this: onBlur={newContent => setContent(newContent.target.innerHTML)} And everything works perfectly 👏🏻

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validation error - Value must be a string - Yii Framework Forum
So I am trying to typecast the necessary value through validation. The way it is written now does not change anything.
Read more >
Value must be of type String: " + parameterName + " - Opster
A detailed guide on how to resolve errors related to "Value must be of type String: " + parameterName + ""
Read more >
Whi i get the error "token must be a string"? - Stack Overflow
I'm trying to use useEffect to set the behaviour for my room and at first, i wanna use the token and roomName to...
Read more >
Date/Time Error: (Operation value must be a string...
I have created a rule to compare a dropdown field and assign a date {{now.plusDays(14)}} to a Date Picker field and am getting...
Read more >
Typeerror: string indices must be integers – How to Fix in Python
We get the "TypeError: string indices must be integers" error when we try to access a character using its string value rather the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found