-
Notifications
You must be signed in to change notification settings - Fork 30
Closed
Description
Hey! What do you think of including the ability to pass custom props to the scripts that could be included either as attributes of the script tag, or as a data- attributes
For eg.
<Script
url="https://someUrl.com"
customProp="customPropValue"
onCreate={onCreate}
onError={onError}
onLoad={onLoad}
/>
At quick glance, the only edit necessary would be to change createScript to grab these props and add them to the script:
createScript() {
const { onCreate, url, ...customProps } = this.props;
const script = document.createElement('script');
onCreate();
if (customProps) {
// to include them as script attributes
Object.keys(customProps).forEach((prop) => {
script.setAttribute(prop, customProps[prop]);
});
// or something like script.setAttribute(`data-${prop}`, customProps[prop]);
}
script.src = url;
script.async = 1;
Metadata
Metadata
Assignees
Labels
No labels