I'm using a file input rendered in the list and somehow onChange handler of one (the first in CodeSandbox example) item is being used for the rest items in the list as their onChange handler when I click the label instead of the input (because I'm planning to hide it later).
React version:
18.2.0
Steps To Reproduce
- Map over any list and render a file input with a label.
- Console.log() the
index from the map in the onChange handler.
- Click the label of any item in the list, not the actual input. It should log
0 for all items. It should work normally as usual if you click input though.
(U can use the CodeSandbox below. These steps are already implemented)
Link to code example:
https://codesandbox.io/s/modern-firefly-8qm4ws?file=/src/App.tsx
Check the console.
The current behavior
One onChange handler is being used for all items in the list when I use a label to trigger input change.
The expected behavior
Every item (input) should have a unique onChange handler as usual in React.
I'm using a file input rendered in the list and somehow
onChange handlerof one (the first in CodeSandbox example) item is being used for the rest items in the list as theironChangehandler when I click the label instead of the input (because I'm planning to hide it later).React version:
18.2.0
Steps To Reproduce
indexfrom the map in theonChangehandler.0for all items. It should work normally as usual if you click input though.(U can use the CodeSandbox below. These steps are already implemented)
Link to code example:
https://codesandbox.io/s/modern-firefly-8qm4ws?file=/src/App.tsx
Check the console.
The current behavior
One
onChangehandler is being used for all items in the list when I use a label to trigger input change.The expected behavior
Every item (input) should have a unique
onChangehandler as usual in React.