/Product.jsx Secret
Last active
October 20, 2022 18:51
Game shop project, Product.jsx file
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 { useEffect, useState } from 'react' | |
import { useParams } from 'react-router-dom' | |
import { loadProduct } from '../Blockchain.Service' | |
import { useGlobalState } from '../store' | |
import Buyers from '../components/Buyers' | |
import Details from '../components/Details' | |
const Product = () => { | |
const { id } = useParams() | |
const [product] = useGlobalState('product') | |
const [buyers] = useGlobalState('buyers') | |
const [loaded, setLoaded] = useState(false) | |
useEffect(async () => { | |
await loadProduct(id).then(() => setLoaded(true)) | |
}, []) | |
return loaded ? ( | |
<> | |
<Details product={product} /> | |
<Buyers buyers={buyers} /> | |
</> | |
) : null | |
} | |
export default Product |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment