import { useState, useEffect } from 'react';

function useLazyRender(show) {
  var _useState = useState(false),
      inited = _useState[0],
      setInited = _useState[1];

  useEffect(function () {
    if (show) {
      setInited(show);
    }
  }, [show]);
  return function (render) {
    return function () {
      return inited ? render() : null;
    };
  };
}

export default useLazyRender;