Skip to content

Instantly share code, notes, and snippets.

@michelts
Created March 22, 2019 13:40
Show Gist options
  • Save michelts/004357d974bafa46e8d527ea0f43fe85 to your computer and use it in GitHub Desktop.
Save michelts/004357d974bafa46e8d527ea0f43fe85 to your computer and use it in GitHub Desktop.
import React from 'react';
import { useGlobal } from 'reactn';
import { getRandomCard } from './utils';
import Card from './card';
const Cards = () => {
const [cards, setCards] = useGlobal('cards');
return (
<div>
{cards.map(card => (
<Card key={card} card={card} />))}
<button
onClick={() => setCards(getRandomCard(cards))}
>Get another</button>
</div>
);
};
export default Cards;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment