简体   繁体   中英

How to add HTML and JS functionality to a React component?

So there is an external service whose only way of accessing their sdk is exampled via a monolithic static website, however I am working with a React app.

I have found that if I use the component in this manner:

import React from 'react';

const acmeID = `<h1>Howdy!</h1>`;

export default function AcmeID() {
  return <div dangerouslySetInnerHTML={{__html: acmeID}} />;
}

I can get this component to render to the screen without having to go into App.js and remove it as a <Route /> and without having to use HTML anchor tags, but I need to utilize a script tag with a JavaScript source to access the sdk. Could I build out a whole HTML markup including that javascript script tag inside that acmeID variable? I just tried putting together an HTML boilerplate markup in there and I got a white screen.

I dont think because react makes an production for these nestings

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM