jpuri / jpuri/html-to-draftjs

Infinite Loop in functional component

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

Nobody has claimed this yet.

Dominant language
HTML
Stars
163
Forks
104
PR merge metrics
No merged PRs in 30d

Description

const ArticleForm = (props) => {

    const {article} = props
    const classes = useStyles();
    const dispatch = useDispatch()
    const router = useRouter()


    const [editorState, setEditorState] = useState(EditorState.createEmpty());


    const blocksFromHtml = htmlToDraft(article.body);
    const { contentBlocks, entityMap } = blocksFromHtml;
    const contentState = ContentState.createFromBlockArray(contentBlocks, entityMap);
    const loadedEditorState= EditorState.createWithContent(contentState);

    debugger

    setEditorState(loadedEditorState)

the setEditorState is causing this error:

image

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 reported infinite loop with the ArticleForm snippet, focusing on the setEditorState call after EditorState.createWithContent. Trace the component's render and state-update sequence, then verify the behavior and its fix with a focused test or reproduction; the payload names no repository file or existing test.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.