You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've successfully ran the react demo/components using the react examples directory and create-react-app. For a separate project I'm trying to use React + Vite with typescript but I'm running in to issues.
If I leave the MoleculeStructure.js as a .js extension then Vite is throwing an error effectively telling me it needs JSX files.
Changing the .js extensions to .jsx I get:
TypeError: window.initRDKit is not a function
at initRDKit.js:15:14
at new Promise (<anonymous>)
at initRDKit.js:13:31
at MoleculeStructure.componentDidMount (MoleculeStructure.jsx:133:5)
at commitLayoutEffectOnFiber (react-dom.development.js:23305:30)
at commitLayoutMountEffects_complete (react-dom.development.js:24688:9)
at commitLayoutEffects_begin (react-dom.development.js:24674:7)
at commitLayoutEffects (react-dom.development.js:24612:3)
at commitRootImpl (react-dom.development.js:26823:5)
at commitRoot (react-dom.development.js:26682:5)`
When I check the type of window.initRDKIT it looks like it's undefined within initRDKIT.js(x)
Based on the typescript examples https://github.com/rdkit/rdkit-js/tree/master/typescript the above error does make sense, but I'm not sure how to convert the typescript solution into this React/Typescript project as 'RDKitModule' is not used (from what I can tell).
For example these typescript are calling RDKitModule which i can find in the javascript examples but cannot locate in React: declare global { interface Window { RDKit: RDKitModule } }
window .initRDKitModule() .then((instance: RDKitModule) => { // window.RDKit is loaded and will be typed as RDKitModule window.RDKit = instance; return instance; })
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've successfully ran the react demo/components using the react examples directory and create-react-app. For a separate project I'm trying to use React + Vite with typescript but I'm running in to issues.
If I leave the MoleculeStructure.js as a .js extension then Vite is throwing an error effectively telling me it needs JSX files.
Changing the .js extensions to .jsx I get:
TypeError: window.initRDKit is not a function
When I check the type of window.initRDKIT it looks like it's undefined within initRDKIT.js(x)
Based on the typescript examples https://github.com/rdkit/rdkit-js/tree/master/typescript the above error does make sense, but I'm not sure how to convert the typescript solution into this React/Typescript project as 'RDKitModule' is not used (from what I can tell).
For example these typescript are calling RDKitModule which i can find in the javascript examples but cannot locate in React:
declare global { interface Window { RDKit: RDKitModule } }
window .initRDKitModule() .then((instance: RDKitModule) => { // window.RDKit is loaded and will be typed as RDKitModule window.RDKit = instance; return instance; })
Beta Was this translation helpful? Give feedback.
All reactions