0.1.0 • Published 2 years ago

jh-react-npm-example v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Primer paquete NPM, prueba prueba

import { ProductCard } from '../components'
<div>
  <h1>Shoping</h1>

  <div>
    <ProductCard
      product={product}
      initialValue={{
        count: 4,
        maxCount: 10
      }}
    >
      {() => (
        <>
          <ProductCard.Image />
          <ProductCard.Title />
          <ProductCard.Buttons />
        </>
      )}
    </ProductCard>
  </div>

  <ProductCard
    product={product}
    initialValue={{
      count: 4,
      maxCount: 10
    }}
  >
    {({ reset, isMaxCountReached, count, increaseBy }) => (
      <>
        <ProductCard.Image />
        <ProductCard.Title />
        <ProductCard.Buttons />

        <button onClick={reset}>Reset</button>

        <button onClick={() => increaseBy(-2)}>-2</button>

        {!isMaxCountReached && (
          <button onClick={() => increaseBy(2)}>+2</button>
        )}

        <span>{count}</span>
      </>
    )}
  </ProductCard>
</div>