V
V
Vadim Stepanenko2019-12-03 01:10:17
React
Vadim Stepanenko, 2019-12-03 01:10:17

A few questions about react?

Hello!
I just started learning React (before that, just layout, a little php on xampp). There were a couple of stupid questions, if you explain I would be very grateful
1. In many tutorials, npm is used to run react applications. What for? React is just a js library that can be connected using the same cdn and just open the .html in the browser.
2. (continuation to question 1). I suppose they start the server with npm start and hang it on the local port, is that so? But then again, why, if the file can just be opened in the browser? And what if the back is on the puff? It turns out that puff and node files will be mixed? This is a bunch of unnecessary files
3. In many tutorials, various imports of various libraries are also prescribed. Is this referring to react or nodejs app?
I apologize in advance for stupid questions

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yustas Alexu, 2019-12-03
@Vadim1899

Many tutorials use npm to run react applications. What for? React is just a js library that can be connected using the same cdn and just open the .html in the browser.

It is with react that this will not work if the goal is to write something more complicated than Hello world.
npm start is just a command in package.json, it can start anything. In the case of webpack, it usually starts webpack-dev-server, which listens on some port on localhost and serves static on that port. It is a local web server replacement for easy development. When building for a real server, use a different command.
You can, but webpack-dev-server automatically updates the page when the code changes (live reload). Plus, when running html from the filesystem, links starting with '/' will work from the root of the filesystem, not from url. And in general there will be problems with links.
The puff backend should be a separate project because React usually works with the backend via a REST API. This means that the backing can be on a different server and in a different country.
import/export is part of the JavaScript language standardized by the EcmaScript specification. Therefore, this part of the syntax is also called esm (EcmaScript modules). The standard is already implemented in modern browsers and recent versions of NodeJS. But to ensure compatibility with various libraries that do not yet use the standard import / export, a webpack-type assembler is needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question