Created
March 3, 2018 04:56
-
-
Save AnielaMW/bfb3e7770d028527d0b85606ec4e4b66 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import StepTile from '../components/StepTile'; | |
import ItemTile from '../components/ItemTile'; | |
import FetchButton from '../components/FetchButton'; | |
class InstructionsContainer | |
extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
// I've added from here to... | |
id: null | |
}; | |
let setSelectedStep = (stepId) => { | |
id = stepId; | |
}; | |
// ... here. | |
} | |
render(){ | |
let supplies = this.props.data.supplies; | |
let directions = this.props.data.directions; | |
let items = supplies.map(supply => { | |
return( | |
<ItemTile | |
item={supply.item} | |
key={supply.id} | |
id={supply.id} | |
/> | |
) | |
}) | |
let steps = directions.map(direction => { | |
let className; | |
let handleClick = () => { | |
this.setSelectedStep(direction.id) | |
} | |
return( | |
<StepTile | |
step={direction.step} | |
key={direction.id} | |
id={direction.id} | |
// and here to... | |
handleClick={handleClick} | |
// ... here. | |
/> | |
) | |
}) | |
return( | |
<div> | |
<h1>How To {this.props.data.activity}</h1> | |
<h3>Supplies:</h3> | |
<ul> | |
{items} | |
</ul> | |
<h3>Instructions:</h3> | |
<ol> | |
{steps} | |
</ol> | |
<FetchButton /> | |
</div> | |
) | |
} | |
} | |
export default InstructionsContainer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
const StepTile = props => { | |
return( | |
// I've added the onClick | |
<li onClick={props.handleClick}>{props.step}</li> | |
) | |
} | |
export default StepTile; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment