uiwjs / uiwjs/react-md-editor

tpye error on `onChange`

Open
#600 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.9k
Forks
201
Avg merge
12m
Merged PRs (30d)
1

Description

When provdigin a the setState Event handler for the onChange event, there is a type mismatch:

const [value, setValue] = useState("**Hello world!!!**");
<MDEditor value={value} onChange={setValue} />
Type 'Dispatch<SetStateAction<string>>' is not assignable to type '(value?: string | undefined, event?: ChangeEvent<HTMLTextAreaElement> | undefined, state?: ContextStore | undefined) => void'.
  Types of parameters 'value' and 'value' are incompatible.
    Type 'string | undefined' is not assignable to type 'SetStateAction<string>'.
      Type 'undefined' is not assignable to type 'SetStateAction<string>'.ts(2322)

versions:

"@uiw/react-md-editor": "^4.0.1",
"typescript": "^4.9.5",

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the TypeScript error with the shown MDEditor and useState example, then inspect the MDEditor onChange type and the package's TypeScript definitions. Done means the example type-checks with the listed TypeScript and @uiw/react-md-editor versions without weakening the reported callback contract.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.