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.

[Bug]: <StrictMode> throws error when used with React 18

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Have you updated React FilePond, FilePond, and all plugins?

  • I have updated FilePond and its plugins

Describe the bug

Hi there,

First off - thanks for an amazing file uploader! It’s rare to find a feature-rich package with top notch UX out of the box.

After upgrading to React 18 and the new createRoot(...) syntax, I am no longer able to load react-filepond. The following error messages are logged:

TypeError
null is not an object (evaluating 'referenceNode.parentNode.insertBefore')
(anonymous function)
[https://codesandbox.io/static/js/vendors~react-devtools-backend.759c29504.chunk.js:1:230840]()
u
[https://codesandbox.io/static/js/vendors~react-devtools-backend.759c29504.chunk.js:1:230954]()
n
[https://codesandbox.io/static/js/vendors~react-devtools-backend.759c29504.chunk.js:1:229900]()
This screen is visible only in development. It will not appear if the app crashes in production.
Open your browser’s developer console to further inspect this error.
This error overlay is powered by `react-error-overlay` used in `create-react-app`.

There also seems to be a typing issue with Typescript for onupdatefiles(...). I get the following issue:

Type 'Dispatch<SetStateAction<never[]>>' is not assignable to type '(files: FilePondFile[]) => void'.

I’m not sure if the two are related. I can clearly see that the class FilePondFile is exported from the library, but Typescript is complaining about the types from the getting started example. Specifying the type in useState<> doesn’t work, because typescript can’t find any exported member for FilePondFile that’s requested by the typechecker.

Any help figuring this out is greatly appreciated!

Thanks, H

Reproduction

Please check out this codesandbox I created to reproduce the issue. All of the specific versions used are detailed there.

Link to sandbox.

Environment

- Device: Macbook Pro, 16 inch (2020)
- OS: MacOS Monterey 12.3.1
- Browser: Chrome, Safari, Firefox
- React version: 18.0

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:9

github_iconTop GitHub Comments

4reactions
hug-0commented, Apr 19, 2022

Thanks.

I’m still stumped. I also removed StrictMode and my sandbox now runs. But my actual project environment still throws the same error. I’m not using StrictMode there either.

React-FilePond runs well in React 17 in my project, but not at all in React 18.

Any suggestions on what I might go looking for to uncover the actual issue?

The log is

filepond.js:1457 Uncaught TypeError: Cannot read properties of null (reading 'insertBefore')
    at insertBefore (filepond.js:1457:1)
    at Object.replaceElement (filepond.js:12086:1)
    at createAppAtElement (filepond.js:12341:1)
    at createApp (filepond.js:12349:1)
    at create (filepond.js:12620:1)
    at FilePond.componentDidMount (react-filepond.js:85:1)
    at invokeLayoutEffectMountInDEV (react-dom.development.js:24926:1)
    at invokeEffectsInDev (react-dom.development.js:27142:1)
    at commitDoubleInvokeEffectsInDEV (react-dom.development.js:27118:1)
    at commitRootImpl (react-dom.development.js:26705:1)

EDIT: As a sidebar, I only get this issue in development mode. In my production build, filepond still works as expected.

2reactions
rikschenninkcommented, May 12, 2022

Should be fixed in 7.1.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

Strict Mode - React
When strict mode is enabled, React compiles a list of all class components using the unsafe lifecycles, and logs a warning message with...
Read more >
How to use React Strict Mode in React 18 - Refine Dev
React Strict Mode can now be used to detect bugs that occur as code runs concurrently (two or more tasks being carried out...
Read more >
React 18 strict mode helped me catch this useEffect bug
All useEffect Mistakes Every Junior React Developer Makes · Is ChatGPT actually useful for coding? · Everything you need to know about React...
Read more >
Using strict mode in React 18: A guide to its new behaviors
The example above would throw an error since · You can enable · A more recommended way of doing this is to wrap...
Read more >
Why React 18 Broke Your App - CoderPad
The reason your app broke in React 18 is that you're using StrictMode . Simply go into your index.js (or index.ts ) file,...
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