Skip to content

JBakouny/React

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A React Web App that integrates with the Node.js Express MongoDB backend

Running the Integrated Application

  1. Installations:

    a. Make sure Node.js is installed.

    b. Make sure yarn in installed. If not, run the below command after :

    npm install -g yarn 
    

    c. Make sure MongoDB is installed on your local machine.

  2. Make sure the MongoDB database is up and running on the path specified in config.js in the backend-code. To run MongoDB locally, execute the below command in a folder containing a directory named "data" :

    mongod --dbpath=data --bind_ip 127.0.0.1
    
  3. Get the back-end's code from the GitHub branch "react-client-integration" and run the Node.js REST API by executing the below command in the NodeBackend directory that will sync from GitHub:

    git clone https://github.com/JBakouny/NodeBackend
    git checkout react-client-integration
    cd NodeBackend
    npm install
    npm start
    
  4. In another folder of your choice, open a new terminal or command line window and clone the front-end code then use yarn to install your dependencies by running the below commands in the folder where you cloned your repo:

    git clone https://github.com/JBakouny/React
    cd React
    yarn
    
  5. Run the following command to start the web app:

    HOST=localhost
    yarn start
    

    If yarn asks you if it should run on another port, reply with "Y" to have it run on port 3001 instead of port 3000. This conforms with the CORS configurations in the backend's code where the whitelist contains "http://localhost:3001".

    To get Google Chrome to accept your self-signed certificate, you should the following: Paste this in your chrome:

    chrome://flags/#allow-insecure-localhost
    

    You should see highlighted text saying: Allow invalid certificates for resources loaded from localhost: Click "Enable".

    See this stack overflow answer for more info.

Routing

The React router enables you to navigate through pages, it also gives you three important props match, location and history as explained here.

Deploying your Mobile First Web Site on the cloud

Here are some cloud providers that ease the deployment of each of the three parts of full stack application:

  • MongoDB Atlas for the database deployment

  • Heroku for the Node.js/Express back-end which constitutes a REST API

  • The React deployment guide would be useful to chose a server that can deliver your Single Page Application (SPA) front-end. Notably, GitHub Pages is a good free choice if you plan to make your code publicly available. Another option uses Heroku and is also detailed here.

Hooks

Hooks are not used in this app but the app could be modified to use hooks with functional components instead of classes. More information on hooks are available here.

JavaScript array destruction syntax might also be useful to learn when developping and viewing code related to hooks.

You need to learn hooks to understand some code on the internet like the online explaining how to create React transitions for animations.

Creating the Initial React App

This first section is part of the ESIB course, it explains how to create your initial react app with Yarn.

  1. Install yarn using globally:

    npm install -g yarn
    
  2. Create your initial react app using yarn:

    yarn add create-react-app
    yarn create-react-app confusion
    

    You should commit your yarn.lock in git, do not add it to .gitignore

  3. Make sure the HOST variable in the terminal (or command line) is set to localhost.

    HOST=localhost
    

    Then install the following dependencies:

    yarn add bootstrap@4.0.0
    yarn add reactstrap@5.0.0
    yarn add react-popper@0.9.2
    
  4. Run the below commands to start your application:

    yarn start
    

    Your react application can now be consulted on http://localhost:3000/

  5. Modify src/App.js and src/index.js in accordance with the Configure React commit.

    View the changes by refreshing http://localhost:3000/

Progressive Web Apps (PWA)

PWAs enable the implementation of of Mobile and Web apps that the same code:

Official Documentation: Getting Started with Create React App

This project was bootstrapped with Create React App.

Available Scripts

In the project directory, you can run:

yarn start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

yarn test

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

yarn build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

yarn eject

Note: this is a one-way operation. Once you eject, you can’t go back!

If you aren’t satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use eject. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

Learn More

You can learn more in the Create React App documentation.

To learn React, check out the React documentation.

Code Splitting

This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting

Analyzing the Bundle Size

This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size

Making a Progressive Web App

This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app

Advanced Configuration

This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration

Deployment

This section has moved here: https://facebook.github.io/create-react-app/docs/deployment

yarn build fails to minify

This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published