Skip to content

Instantly share code, notes, and snippets.

@faustoct1
Created November 28, 2023 04:46
Show Gist options
  • Save faustoct1/b191a63d61889036cd2df5bda37ae003 to your computer and use it in GitHub Desktop.
Save faustoct1/b191a63d61889036cd2df5bda37ae003 to your computer and use it in GitHub Desktop.
/**
See the documentation here https://daily-launches.web.app/plugins/subscribe
**/
import React, { useEffect, useState } from 'react';
import { View, Text } from 'react-native';
const ExampleView = ({show,handleClose}) => {
const loadScript = (url) => {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = url;
script.onload = resolve;
script.onerror = (error) => {
console.error(`Error loading script from ${url}:`, error);
reject(error);
};
document.head.appendChild(script);
});
}
useEffect(()=>{
loadScript('http://daily-launches.web.app/plugins/subscribeButton.js')
.then(() => {
// Assuming `initializeSubscribeButton` is available globally after script execution
initializeSubscribeButton('light', 'subscribeButtonContainer', 'add-your project id');
})
.catch((error) => {
console.error('Script loading failed:', error);
});
return () => null
},[])
return (
<View style={{flex:1}}>
<Text>Testing subscribe button..</Text>
<View id="subscribeButtonContainer">
</View>
</View>
)
}
export default ExampleView;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment