tut-react-and-spring-data-rest icon indicating copy to clipboard operation
tut-react-and-spring-data-rest copied to clipboard

Part 3 app.js UpdateDialog input key issue

Open jamesyin96 opened this issue 7 years ago • 3 comments

Hi,

Thanks for this awesome tutorial. I learned good react design here. But I do find a place that could be better.

It's in Part 3 - Conditional Operations. In UpdateDialog component, when we define the form input, we set

<p key={this.props.employee.entity[attribute]}>

This works most of the time, but it can't guarantee the key uniqueness. If firstName = lastName, we will have a problem. If we set

<p key={attribute}>

It can solve this problem because attributes are different by design. I notice we use this key assignment in CreateDialog component. So UpdateDialog component should follow the same pattern, right?

Thanks

jamesyin96 avatar Apr 02 '17 18:04 jamesyin96

Well, the ideal key would be a "self" link URI.

gregturn avatar Apr 02 '17 21:04 gregturn

Yes, that's even better. :)

jamesyin96 avatar Apr 02 '17 22:04 jamesyin96

Pull request welcome. Just be sure to hit each section. :)

gregturn avatar Apr 02 '17 22:04 gregturn