{"size": 574, "ext": "js", "max_stars_repo_path": "src/components/Product/index.js", "max_stars_repo_name": "Duwahiner/aflore-product", "max_stars_repo_stars_event_min_datetime": "2021-02-22T19:27:22.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-22T19:27:22.000Z", "max_issues_repo_path": "src/components/Product/index.js", "max_issues_repo_name": "Duwahiner/aflore-product", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/Product/index.js", "max_forks_repo_name": "Duwahiner/aflore-product", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.0769230769, "max_line_length": 52, "alphanum_fraction": 0.5836236934}
import React, { useEffect, useState } from 'react'
import ProductItems from './components/PorductItems'

const Product = ({ product }) => {
  const [extract, setExtract] = useState(product)

  useEffect(() => {
    if (typeof product === 'object') {
      if (Object.keys(product).length > 0) {
        if (product.children.length > 0) {
          setExtract(product)
        } else {
          setExtract(product)
        }
      }
    } else {
      setExtract(product)
    }
  }, [product])

  return (
    <ProductItems product={extract} />
  )
}
export default Product
