score:0
either you add it in the index.html
at public folder, assuming that you are using create-react-app
or you can add it programmatically, for instance:
function freshchat(props) {
const body = useref();
useeffect(() => {
const fc_js = document.createelement('script');
if (!window.fcsettings) {
fc_js.type = 'text/javascript';
fc_js.src = 'https://my-source-of-js.com/js/yourjs.js';
if (body.current) {
body.current.appendchild(fc_js);
}
}
return () => {
body.current = null;
};
}, [body]);
return <div ref={body} classname="print:hidden" />;
}
Source: stackoverflow.com
Related Query
- Where do I add <script> tags to React components?
- Dynamically add child components in React
- How do I use external script that I add to react JS?
- Add ld+json script tag in client-side React
- How to add Stripe.js script in React component
- How do I add the Intercom script in my React app?
- How to add components to list dynamically in React with no redundant render?
- HTML script is loading AFTER react components
- Using included script in index.html in React components
- How to add React components to existing Django project
- React Native: How to add script tag in the component
- Where do you add .d.ts files in React Native
- Add value to React context from child components
- Add methods to Higher Order Components in React
- Which React Material-UI components add a spacing to my page (like a row class in Bootstrap)?
- react - can you mutate modify this.props.children to dynamically (programatically) add children components
- React Higher Order Components to add a custom attribute to the rendered JSX
- React where in the component to add a simple math function
- How to add a CSS class to an element with React function components
- react multiple components add item
- How to add "active" class to styled components in React
- How to add 'title' tag (for tooltip) in react styled components
- How to test React components inside react-responsive tags
- How to add async attribute to script generated by react scripts (at the npm run build stage on the create-react-app template)
- How to add script to React component and use as constructor function
- How to add animation in dynamically created react components
- How to change the html meta tags with react function components
- How to add a custom script into React app component?
- Dynamically add children to React components
- Add prop dynamically to last element in an array of React components
More Query from same tag
- How to change the signal button background color in 10 buttons?
- Laravel Mix - Integrate web3 react app into laravel
- Issue facing with storybook for React Please guide me
- How to export mapStateToProps and Redux Form?
- React watch imported class property
- Use custom function for CSS property in styled-components?
- npm ERR! missing script: jasmine
- React Hook useEffect Error missing dependency
- React object state not persisting while calling in multiple functions
- How can i set only value on react select
- ReactJS - ReactMount: Root element has been removed from its original container. New container
- Module not found: Can't resolve '@material-ui/core/AppBar'
- Making a table in react js without proper key values in json data
- Post Data With Redux and Fetch API with Axios Get Error Result so Looping Response Pending
- How to use setState with nested JSON array object
- Declare font size for html element for various breakpoints in MaterialUI
- React throws error when using ajax before redirect
- Prevent adding backslash to \n special character in a string
- How to allow for input change in rendered reactjs component? Do I lift up State?
- react-google-maps is refreshing the map when onclick is performed
- react-router-dom(ReactJS) nesting <Link /> components
- GraphQL defaulting data causes infinite loops in useEffect
- How to render images of unknown dimensions using next/image from Next.js?
- parse body of react tag
- onDargStart eventlistener outputs null values in react
- How to validate phone number in react that until user give valid phone number button should disabled
- React/Redux Handling Two-Way Data
- ReactJS First fetch is undefined
- Accessing Redux Store from routes set up via React Router
- Can't upload image in ckeditor