Tell the beginner: there is an imposed page with all sorts of multi-selects, searching for it, and so on. I want to rewrite all jQuery to React, respectively, and turn over some components and parts of the project. Tell me how to add React to the project. Json file is created on the local run, i.e. npm dependencies added, but how to actually "inject" React was not found anywhere. If not difficult, tell me ..
1 answer
The answer to your question can be found on the official library page: https://facebook.imtqy.com/react/docs/installation.html
To install React via npm, you should enter the following command:
npm install --save react react-dom After that the library will be added to the dependency file of your project. Now you can connect and use it.
An example of use, again, is listed on the page above:
import React from 'react'; import ReactDOM from 'react-dom'; ReactDOM.render( <h1>Hello, world!</h1>, document.getElementById('root') ); - Do I need to add a Gulp type collector or Bower package managers, for example, or can I do? - Vladyslav Tereshyn
- 2It all depends on the tasks you are pursuing. Of course, you can do without Gulp. You can write code using React by installing and connecting the modules necessary for this library, which are indicated in my answer. If you want to use JSX in your code, you will have to plug in a compiler that will translate your JSX code into JavaScript code, which is understood by React. Use Babel for this. Again, everything is written about the installation on the official website: babeljs.io/docs/setup/#installation. You can simply download the babel and connect it to html as a script. Everything will work. - Uladzislau Radzko
- Thanks for the detailed answer! - Vladyslav Tereshyn
|
create-react-app? - DimenSi