DEV Community

Discussion on: How to use previously packaged ReactJS component in static website

Collapse
 
jonasbn profile image
Jonas Brømsø

Hi @jvarghese

Have you tried StackOverflow or similar as a forum to get your question answered?

I am by no means a JavaScript or React developer, but my suggestion would be to make the simplest version using React that you possibly can, meaning even simpler than what you demonstrate.

If you read up on the error is might be due to the component not being available (ref)

  • Can you demonstrate that React works?
  • Can you demonstrate that your component is loaded?
  • Can you demonstrate that your component is initiated?
  • Can you recreate the problem outside Apache using React tools?
Collapse
 
jvarghese profile image
JVarghese99

I managed to get my example working by adding the following line to the ReactJs project

(window as any).ExButton = ExButton

I am not sure if there is any better way.

Collapse
 
jonasbn profile image
Jonas Brømsø

Glad to hear you got it to work.

Just out of curiosity - and only respond if you have the time.

  • What led you to the solution?