файл где пишет ошибку ItemUrgency:
import React, {Component} from 'react';
import {
Button
} from 'reactstrap';
//import views
import DeleteProblem from '../Modals/DeleteProblem';
export default class ItemUrgency extends Component {
constructor(props) {
super(props);
this.state = {
editing: false,
urgency: this.props.urgency
};
}
handleClick = () => {
this.setState({
editing: !this.state.editing
});
};
render(){
return(
<tr>
{!this.state.editing ? [
<td>{this.props.urgency.problem}</td>,
<td>{this.props.urgency.time}</td>,
<td className='text-center'>
<Button color='primary' onClick={this.handleClick}>редактировать</Button>
</td>
] : [
<td><input className='form-control' type='text' value={this.props.urgency.problem}/></td>,
<td><input className='form-control' type='text' value={this.props.urgency.time}/></td>,
<td className='text-center'>
<Button color='success' onClick={this.handleClick}>сохранить</Button>
</td>
]}
<td className='text-right'>
<DeleteProblem/>
</td>
</tr>
);
}
}
файл где происходит итерация и по идеи должен быть ключ ItemsUrgency:
import React, {Component, PropTypes} from 'react';
//import views
import ItemUrgency from './ItemUrgency';
export default class ItemsUrgency extends Component {
constructor(props) {
super(props);
this.state = {
editing: false,
urgency: this.props.urgency
};
}
static propTypes = {
urgency: PropTypes.array
};
handleClick = () => {
this.setState({
editing: !this.state.editing
});
};
render(){
return(
<tbody>
{this.state.urgency.map((item) =>
<ItemUrgency key={item.item} urgency={item} />
)}
</tbody>
);
}
}
сама ошибка:
Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of ItemUrgency
. See https://fb.me/react-warning-keys for more information.