bvaughn / react-window

React components for efficiently rendering large lists and tabular data
https://react-window.now.sh/
MIT License
15.48k stars 778 forks source link

Input is losing focus , when wrapped with VariableSizeList #755

Open pst37 opened 4 months ago

pst37 commented 4 months ago

I have wrapped a input element inside VariableSizeList. When there is change in input component, the input component is losing focus , because whole component is getting remounted or i can say react is re-creating whole new tree.

I have added the example here. Example here

Steps:- 1.) Open Element tab in dev-tools 2.) type anything in any input box

You will notice the wrapper of all new input is getting updated ...

Dimitrov-Codes commented 4 months ago

I am facing the same issue . Are there any workarounds to this??

h7y commented 2 months ago

Moving the renderer 👇 to a separate function as shown in the docs would fix this :)

{({ index }) => (
  <div className="test">
    <input
      type="text"
      placeholder="search"
      value={searchText[index]}
      onChange={(e) => onChange(e, index)}
    />
  </div>
)}