Answer the question
In order to leave comments, you need to log in
What should be the structure of a React site?
Let's say I want to make a conditional chat blog. I used to make only simple sites using html, css, js, php and now I learned a little about react and used create-react-app for this. The only structure for a react blog came to my mind - in public'e index.html, profile.html, admin_profile.html, chat.html, a folder for styles, a folder for static js files. At the root of the project, there is also a folder with php scripts that will execute the entire backend using requests for them. And the question is, we have only one exact entry into the project where App.js is rendered, in which all react components are collected and how to render components to another html file, or in general, what should be the structure of a multi-page site on react?
Answer the question
In order to leave comments, you need to log in
https://react-file-structure.surge.sh/
https://mobile.twitter.com/dan_abramov/status/1027...
// edit
depends on requirements. If you need SEO indexing - one way, if not - another. Further dance on the support of devices, the number of pages, and a bunch of other factors. It is definitely not necessary to put a bunch of html files in the public folder.
For blogs look towards Gatsby/NextJS
Typically, react is used for SPAs, i.e. single page application. That is, there is only one entry point to the application - index.html, on which the application script is connected. Additional addresses are usually handled by client-side routing (see react-router for an example). Those. for all requests, the backend will return index.html, and the url itself will be parsed at the front.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question