tut-react-and-spring-data-rest
tut-react-and-spring-data-rest copied to clipboard
Part 3 app.js UpdateDialog input key issue
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
Well, the ideal key would be a "self" link URI.
Yes, that's even better. :)
Pull request welcome. Just be sure to hit each section. :)