Socket
Book a DemoInstallSign in
Socket

@escaladesports/react-esca-api

Package Overview
Dependencies
Maintainers
6
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@escaladesports/react-esca-api

React components & hooks for using Escalade Sports API data

latest
npmnpm
Version
0.2.0
Version published
Maintainers
6
Created
Source

react-esca-api

React components & hooks for using Escalade Sports API data

Example Code

import React from 'react';
import {
  ProductsProvider,
  useProducts,
  Products,
} from '@escaladesports/react-esca-api';

const options = {
  site: 'lifeline',
  env: 'prod',
  fields: ['inventory', 'price'],
  salsify: ['Web Images'],
};

const CustomComponentWithHook = () => {
  const [products] = useProducts(options);
  return (
    <section>
      {!products
        ? <div>Loading...</div>
        : products.map(product => (
          <div key={product.sku}>
          <hr />
          <span>
            {product.sku} - {product.name}
          </span>
          <br />
          <span>
            {product.price} - {product.stock}
          </span>
          <hr />
        </div>
        ))}
    </section>
  );
};

// Note: <Products> renders a basic default display if no children specified
const CustomComponentPlain = () => (
  <Products options={options}>
    {({ products, loading }) => (loading
      ? <div>Loading...</div>
      : products.map(product => (
        <div key={product.sku}>
          <hr />
          <span>
            {product.sku} - {product.name}
          </span>
          <br />
          <span>
            {product.price} - {product.stock}
          </span>
          <hr />
        </div>
      )))}
  </Products>
);

export default function Test(props) {
  const { useComp } = props

  return (
    <ProductsProvider>
      {useComp ? <CustomComponentPlain /> : <CustomComponentWithHook />}
    </ProductsProvider>
  );
}

FAQs

Package last updated on 26 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts