'use strict';

var React = require('react');

/**
 * Store a value between renders and return what it was assigned previously.
 *
 * @param {*} value something you want to store the value of between renders to do comparisons against
 * @param {*} initialValue the initial value stored in the ref
 * @returns * the value passed to the hook on the previous render
 */
function usePrevious(value, initialValue) {
  var ref = React.useRef(initialValue);
  React.useEffect(function () {
    ref.current = value;
  });
  return ref.current;
}

exports.usePrevious = usePrevious;
