Last active
April 18, 2020 20:51
-
-
Save jsmney/048675e49bfd2220471318c167460290 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 => { | |
// for example's sake, here is a default array of birds | |
const [birds, setBirds] = useState([ | |
{id: 3, name: 'Polly', fed: false}, | |
{id: 4, name: 'Tina', fed: true}, | |
{id: 5, name: 'Marlow', fed: false} | |
]) | |
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} />} | |
</> | |
) | |
} | |
export default BirdSanctuary |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment