javascript - How to create react components so that each component has a unique id -
i want tract components id, want ensure each component of class have unique id.
should use higher order components?
or create factory function:
nextid = 1; function componentfactory(props) {   return (     <component id={nextid++} {...props}/>   ); }   this approach not pretty because can't use <> angle brackets create component.
my use case is:
i have list of todos each todo should placed on specific coordinate.
a todolist component holds state of coordinates each todo item associating coordinate todo
id.later want add new todo, update store add new todo.
todolist component looks
idof each todo item , finds specific coordinate item.if can't find coordinate id, randomly assigns new coordinate.
 
 
Comments
Post a Comment