Last active
April 20, 2020 16:48
-
-
Save jsmney/2860e7e15b810fbec7db15f636d0e16b to your computer and use it in GitHub Desktop.
This file contains 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, {useState, useEffect} from 'react' | |
const BirdSanctuary = props => { | |
const [birds, setBirds] = useState([]) | |
useEffect(()=>{ | |
setBirds(props.getBirds()) | |
},[]) | |
const feedBird = birdId => { | |
// updates bird feed status locally and on our database | |
} | |
return ( | |
<> | |
<h1>Welcome to the Jasmine Bird Sanctuary</h1> | |
{birds.map(bird => <SingleBird bird={bird} feedBird={feedBird} />} | |
</> | |
) | |
} | |
BirdSanctuary.defaultProps = { | |
getBirds: () => [ | |
{id: 3, name: 'Polly', fed: false}, | |
{id: 4, name: 'Tina', fed: true}, | |
{id: 5, name: 'Marlow', fed: false} | |
] | |
} | |
export default BirdSanctuary |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment