How to use react-script-hook - 2 common examples

To help you get started, we’ve selected a few react-script-hook examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hupe1980 / wapps-components / packages / react-stripe-checkout / src / StripeCheckout.js View on Github external
export default function StripeCheckout(props) {
  const { apiKey, src, LoadingIndicator, ErrorIndicator } = props;
  const [loading, error] = useScript({
    src,
  });

  if (loading) return ;
  if (error) return ;

  const handler = window.StripeCheckout.configure({
    key: apiKey,
  });

  const children = React.cloneElement(props.children, {
    onClick: event => {
      event.preventDefault();
      const options = getOptionsFromProps(props);
      handler.open(options);
    },
github hupe1980 / wapps-components / packages / react-google-maps / src / components / GoogleMaps.js View on Github external
export default function GoogleMaps(props) {
  const { api, children } = props;
  const [loading, error] = useScript(getAttributes(api));

  if (loading || error) return null;

  return (
    
      <>{children}
    
  );
}

react-script-hook

React hook to dynamically load an external script and know when its loaded

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis

Popular react-script-hook functions