Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-stripe-script-loader

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-stripe-script-loader - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

4

package.json
{
"name": "react-stripe-script-loader",
"version": "1.0.5",
"version": "1.0.6",
"description": "React component that lets load Stripe script and shows React Stripe Elements",

@@ -8,3 +8,3 @@ "main": "index.js",

"test": "echo \"Error: no test specified\" && exit 1",
"build": "./node_modules/.bin/babel src/index.js --out-file index.js"
"build": "./node_modules/.bin/babel src --out-file index.js"
},

@@ -11,0 +11,0 @@ "repository": {

import React, { useState, useEffect } from 'react'
import loadScript from './loadScript'

@@ -12,2 +11,23 @@ const StripeScriptLoader = ({

useEffect(() => {
const loadScript = (src, uniqueId) =>
new Promise((resolve, reject) => {
const scriptElement = document.getElementById(uniqueId)
if (!scriptElement) {
const script = document.createElement('script')
script.src = src
script.id = uniqueId
const handleLoadScriptSuccess = () => resolve({ successful: true })
const handleLoadScriptFail = event => reject({ error: event })
script.addEventListener('load', handleLoadScriptSuccess, {
once: true,
})
script.addEventListener('error', handleLoadScriptFail, { once: true })
document.head.appendChild(script)
} else {
resolve({ successful: true })
}
})
const fetchData = async () => {

@@ -14,0 +34,0 @@ const result = await loadScript(script, uniqueId)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc