react and redux app deployment : does the server receives all states? - reactjs

Im trying to build a website with React and using django backend.
I would like to know if using a React application I will need a server running React with
npm start app
or
yarn start app
or if I need to use npm build and upload the index.html with the corresponding js files and the folder structure on my server?
In both cases what happens to the "states" used in react and redux ? are they transmitted to the server running npm start for example? in the case of a build are they also transmitted to the server?
I would like to know that for scalability issues.
thank you.

React and Redux are both client-side only. They only live in the browser unless you manually write code to send data back.
Usually you would yarn build and upload the result of that.

Related

Data from back end not passing to react app after deployment

I created a server-side and deployed it on Heroku so I have a URL from Heroku that I can see the data transferred from the backend when I enter that URL.
I put that link in the react app package.json file as "proxy" and when I run the react app locally I can see the data from the backend rendered on the website.
I have tried to deploy the react app on Heroku and netlify and on both you can see only the react components rendered without the data that is supposed to be transferred from the backend.
any idea why is that?
In my opinion it has to be something related to the build folder since that run the app locally works great
****update:
After running the build version locally i can see the data is not passed so I'm assuming something is wrong with the build version

Connect create-react-app to django backend without having to run build

I connected my react app that I made with create-react-app to django by passing it in as a template. I followed the steps shown here: https://studygyaan.com/django/django-react-setup-best-project-structure.
This works but if I want to try out a full backend server by running manage.py runserver, I have to do npm run build on the frontend app all the time. Is there a way to get it so that I could maybe connect the development components to django instead of the build components? Running the build command always takes a bit of time.

Update changes on React + Django without running "npm run build" everytime

My Django + React app is integrated fine at least for most parts. Because every time I have to make changes on my React code, in order to apply those changes I have to stop django from running then run npm run build everytime.
I've already read this is there any way to run React + Django in same project without running npm run build again and again? and tried to apply it to my problem but it didn't work.
Still new in React but with a few experiences with Django. Would appreciate your help
When developing with Django and react I have often found it easier to import libraries (the minified versions usually) through script tags in the html that is served to the front end, this entirely circumvents the need to have npm in use entirely. If you do switch to this method, simply make sure that debug is set to true and you will be able to start the server by running 'python manage.py runserver' and you'll be able to access everything on the Django port that you are using.

How deploy React app locally only in my PC?

I’m working on a project. In this project, I'm creating a React user interfaces to enter data. So now, I only can run the React project with npm start. That mean I need code to run the project
Is there any way to deploy my project locally? I mean, I need a way to run the React project without use of code. I need to deploy only on my local PC.
You can do this following:
Build your react project
Use server and visit your url. ex: localhost:8887
You can use Web Server for Chrome for server.
Consider checkbox:
If you check those checkboxes, others can access your site.

Does a React application HAVE to run on its own server process?

I come from a background in Angular, but I wanted to start learning React. I want to make a React front-end for a nodejs Express web service.
In Angular, I could simply build the source code into a static folder with a standard index.html, and it can be deployed on any web server. With React however, every tutorial I see is about running React in its own server using create-react-app and npm start.
I know you can also just use script tags to import the React framework in a static page, but then you can't use JSX syntax, and I would like to. Is it possible to simply build a React project into a static folder with an index.html that can be deployed on any web server?
Yep, you can do what you're describing. If you want to use JSX syntax, you'll need Babel, which transpiles it into standard JavaScript.
You can avoid the complexities of setting it up by using create-react-app to create the app, then running npm build instead of npm start. This will compile everything into a build directory, complete with index.html.
CRA uses its server for development purposes. You don't need CRA for using React of course. But, as your app getting bigger and bigger you will need some more extra tools. For example you want to see your code instantly without refreshing your browser. Here comes the dev server and hot reloading.
CRA uses Webpack behind the scenes. It is a great tool for bundling (obviously) all your files (including css), minifying, uglifying, optimizing your code etc.
For simple code or testing purposes using one file and attaching React and Babel to your file could be enough but for real apps you will need more. Either you will use something like Webpack on your own or you will use CRA and let it do all the extra stuff for you.

Resources