Skip to content

Instantly share code, notes, and snippets.

View dfrho's full-sized avatar

David Rhodes dfrho

View GitHub Profile
@dfrho
dfrho / useRandomProduct.js
Created October 19, 2019 20:43
hook for randomizing one product from mock json product data
import { useState } from 'react';
import PropTypes from 'prop-types';
import * as mockReviews from '../mockReviews.json';
const TOTAL_MOCK_REVIEWS = 100;
const randomProductIndex = () => {
return Math.floor(Math.random() * Math.floor(TOTAL_MOCK_REVIEWS - 1));
};
const useRandomProduct = () => {