Skip to content

Commit

Permalink
Fix React warning about unique keys
Browse files Browse the repository at this point in the history
Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `Explain`. See https://fb.me/react-warning-keys for more information.
    in div (created by Explain)
  • Loading branch information
odegroot committed May 28, 2017
1 parent 1a4fba1 commit 08d50f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
8 changes: 3 additions & 5 deletions explain.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ App.Explain = class Explain extends React.Component {
this.props.onRequestClose();
}

// Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `Explain`. See https://fb.me/react-warning-keys for more information.
// in div (created by Explain)
render() {
var style = {
content: {
Expand Down Expand Up @@ -63,11 +61,11 @@ App.Explain = class Explain extends React.Component {
var assemblyLinesExplanation = null;
if (recipe.type != "fluid") {
assemblyLinesExplanation = [
<div className="section"># Assembly Lines</div>,
<div>
<div key="1" className="section"># Assembly Lines</div>,
<div key="2">
One lane of your chosen transport belt can transport only { decimalNumber(this.props.options.beltlvl * 60) } {madeUnits}/min. Since one { madeBySingular } produces at a rate of { decimalNumber(60 / recipe.assemblyTime) } {madeUnits}/min, if { wholeNumber(recipe.assemblersPerLine) } or more { madeByPlural } output onto the same belt, then the belt will back up, limiting production.
</div>,
<div>
<div key="3">
Since you need { wholeNumber(recipe.assemblersRequired) } { madeByPlural }, this means you will need { decimalNumber(recipe.lines) } separate belt lines, which in real life means { wholeNumber(recipe.lines) } belt lines.
</div>
];
Expand Down
22 changes: 9 additions & 13 deletions options.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,21 @@ App.Options = class Options extends React.Component {
this.props.onChangeOptions(this.props.options);
}

// Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `Options`. See https://fb.me/react-warning-keys for more information.
// in option (created by Options)
render() {

if (this.state.showOptions) {

var oldBeltOptions = [
<option value="3.8">Basic (slow corners)</option>,
<option value="5.7">Basic (straight)</option>,
<option value="6.3">Fast (slow corners)</option>,
<option value="9.4">Fast (straight)</option>,
<option value="8.3">Express (slow corners)</option>,
<option value="14.2">Express (straight)</option>
<option key="3.8" value="3.8">Basic (slow corners)</option>,
<option key="5.7" value="5.7">Basic (straight)</option>,
<option key="6.3" value="6.3">Fast (slow corners)</option>,
<option key="9.4" value="9.4">Fast (straight)</option>,
<option key="8.3" value="8.3">Express (slow corners)</option>,
<option key="14.2" value="14.2">Express (straight)</option>
];

var newBeltOptions = [
<option value="6.66">Basic</option>,
<option value="13.33">Fast</option>,
<option value="20.00">Express</option>
<option key="6.66" value="6.66">Basic</option>,
<option key="13.33" value="13.33">Fast</option>,
<option key="20.00" value="20.00">Express</option>
];

var beltOptions;
Expand Down

0 comments on commit 08d50f3

Please sign in to comment.