Home > Software engineering >  Converting existing site to React JS (Adding ReactJS to existing webpage)
Converting existing site to React JS (Adding ReactJS to existing webpage)

Time:02-12

I am kinda new to front web development, but there is one interesting question for me.

I got a simple vanila html css js website, in which I want to integrate a few actions (profile page, custom e-commerce, checkout, etc) using React.

As I followed this tutorial (Add React in One Minute), I had successfully "inserted" react component into the webpage. But the normal reactjs applications are able to use installed libraries, use props to pass data.

So, basically, the question is how to run this webpage the way that react will be able to handle libraries installation (common npm i example) in order to be able to import them and work like with normal react application created by npx create-react-app my-app

CodePudding user response:

You could use libraries via a CDN link, the same way you added React via a script-tag to your site. Ultimately i think you're looking for the developer experience one gets while using JSX-syntax and this would require you to rewrite your exitsing app, achieved trough setting up a node project with your mentioned command npx create-react-app <app-name>.

JSX must be compiled to regular JavaScript so that browsers can interpret them correctly, much like you would compile a C program to a binary file.

  • Related