- Clone the repo
- Make sure that you have Node.js v14 and npm v6 or above installed
npm install
npm start
- Read this first!
- Points need to be understood to do the components structure below (Master Page)
- react state & props
- react hooks: useState
- sass / scss (css preprocessor)
- Create our own components from scratch
- Reusable components
- TextField
- Button
- Header
- Avatar
- Sidebar
- Pages
- Master Page
- Login
- Dashboard
- Posts
- Reusable components
- The app document / components structure
- App
- Master Page
- if => loggedIn == false
- Login
- Login Form
- Login
- if => loggedIn == true
- Sidebar => [Dashboard, Posts]
- Main Content Wrapper
- Header
- Header Title
- Logout Button
- Avatar
- Main Content
- if => Sidebar == Dashboard
- Dashboard
- if => Sidebar == Posts
- Posts
- if => Sidebar == Dashboard
- Header
- if => loggedIn == false
- Master Page
- App
- react states
- user => object { username: '', name: '' }
- loggedIn => boolean
- selectedSidebar => integer
- Constants
- available users (dummy data) => check when logging in
- Read this first!
- Configure redux store and actions (modify index.js)
- Save react states from previous chapter into global states using redux
- Read this first!
- Use axios as http client to consume 3rd party web service
- Web service: https://jsonplaceholder.typicode.com/
- Modify Posts page, now it will contains two tables (its data are coming from 3rd party web service)
- Table [posts]
- https://jsonplaceholder.typicode.com/posts
- Fetch posts data when Posts page is rendered at the first time (using react hooks: useEffect)
- Table [comments]
- https://jsonplaceholder.typicode.com/post/{postId}/comments
- Fetch comments data when selected row in posts Table is updated
- Table [posts]
- Read this first!
- Use React Router as client-side url routing
npm install react-router-dom@6 --save
- Routing requirements
- "/dashboard" => Dashboard page
- "/posts" => Posts page
- Logging out => redirect to "/"
- Logging in => redirect to current url in browser
- Example: if current browser url = "/posts", then after successfully logging in, redirect to Posts page
- If current browser url is not matched to any defined routes, then redirect to Dashboard page
- Read this first!
- Save login username to localStorage when successfully logging in
- Clear login username from localStorage when logging out
- Check on MasterPage component using useEffect if there is matching username saved in localStorage
- If there is a user found, redirect to correct route similar with requirement in previous chapter
- ReusableTable component
- Built using react-table and react-loader-spinner
- Update tables in Posts page using ReusableTable component (located in "/src/components/ReusableTable/" directory)
- Based on Create React App react-scripts v5
- React v17
- State management:
- react-redux
- redux
- redux-logger
- redux-thunk
- Linting: eslint-config-airbnb
- Webpack Hot Module Replacement (HMR) enabled
- Other important packages:
- @microsoft/signalr: javascript client for .NET Core SignalR (WebSocket protocol)
- axios: HTTP client
- http-proxy-middleware: configure proxy middleware for outgoing HTTP request and WebSocket communication
- sass: css pre processor
- react-app-rewired: tweak the create-react-app webpack config(s) without using 'eject' and without creating a fork of the
- react-router: client side url routing react-scripts.
- customize-cra: react-app-rewired helper.
- react-dnd: enable to build complex drag and drop interfaces
- react-intl: internationalization
- Make sure that you have Node.js v14 and npm v6 or above installed.
- Navigate to project root directory.
- Configure REST and WebSocket API ports in /src/setupProxy.js file.
- Configure additional webpack config in /config-overrides.js file.
- Execute
npm install
to install package dependencies. - Execute
npm start
to run the app in development mode. - Now you are ready to rumble!
In the project directory, you can run:
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.
Launches the test runner in the interactive watch mode.
See the section about running tests for more information.
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.
Note: this is a one-way operation. Once you eject
, you can’t go back!
Use react-app-rewired instead
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.
Execute linting for .jsx and .js files in src directory
You can learn more in the Create React App documentation.
To learn React, check out the React documentation.
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify