Below you will find pages that utilize the taxonomy term “React”
How to use absolute imports with React
Starting from React scripts you can now use absolute imports to use your components.
What’s the problem?
Imagine you have the following simple code structure.
/src
--/Components
--/Home/Top.js
--/A/Really/Deep/Component.js
--App.js
If you wanted to import, say… Top into App, you would normally do:
App.js
import Top from './Home/Top'
So what’s the problem?
Imagine you want to import Top into Component, then you would have:
import Top from '../../../../Home/Top'
Did you count the folders I went back? I didn’t so it might not match.
Easy deploy your react server with Nginx
Now you have your react project and you want to create a simple deploy server.
Install your host server. We are going to use a Nginx proxy server. This is an example for a Debian based system.
sudo aptitude install nginx-light
For this example we don’t need the full Nginx server.
Nginx creates a default host file. Then you can place the content of your build files under /var/www/default and it should be enough.