Jaaneek / useFilePicker

Simple react hook to open browser file selector.

Home Page:https://use-file-picker.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Renders Twice

Kenneth-Fernandes-0620 opened this issue · comments

This Custom Hook renders the component it is used in 'twice'

useFilePicker Custom Hook Multiple Render

Above is a screenshot of the Simple txt file content reading usage example in codesandbox.
We can see that by just adding a console statement that the Component using the hooks is rendering twice

I cant check it right now but I will give my opinion.

  1. Isnt this related to react strictmode, when we are using that every component will be rendered twice at mount to detect memory leaks and other side effects faster.
  2. Even if it is rendering the component twice, is that a problem? Can you elaborate why should we avoid it? React usually does a lot of unnecessary rerenders and common approach is to optimise it only when something is lagging.

Thanks a lot @Jaaneek , yes this issue was related to The Strict Mode in React