Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

script tag inside react component

import { useEffect } from 'react';

const useScript = url => {
  useEffect(() => {
    const script = document.createElement('script');

    script.src = url;
    script.async = true;

    document.body.appendChild(script);

    return () => {
      document.body.removeChild(script);
    }
  }, [url]);
};

export default useScript;
Comment

script tags in react

componentDidMount () {
    const script = document.createElement("script");

    script.src = "https://use.typekit.net/foobar.js";
    script.async = true;

    document.body.appendChild(script);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: check radio button jquery 
Javascript :: resize canvas javascript 
Javascript :: how to copy an arry react 
Javascript :: javascript closure function example 
Javascript :: mangoose connection 
Javascript :: add an object to index 0 array js 
Javascript :: js array contains 
Javascript :: load new site with javascript 
Javascript :: download pdf in javascript 
Javascript :: import and export type in js 
Javascript :: js return the highest and lowest number 
Javascript :: mui react outlined input helperText 
Javascript :: yup validation based on another field value 
Javascript :: scroll out js threshold 
Javascript :: AngularJS how to use btn-group or radio group in list 
Javascript :: regex match any character 
Javascript :: how to generate random text in vue js 
Javascript :: javascript round to nearest integer 
Javascript :: trim string in javascript 
Javascript :: adding logo to vscode extension development 
Javascript :: javascript import class 
Javascript :: simplexml format xml 
Javascript :: how to target checkbox in jquery 
Javascript :: Return the highest number in Arrays in JavaScript 
Javascript :: get data from google sheets javascript 
Javascript :: stack example in javascript 
Javascript :: javascript add to home screen button 
Javascript :: confluent kafka nodejs 
Javascript :: chrome.runtime.sendMessage 
Javascript :: angular injectiontoken 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =