React codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.
This codebase was created to demonstrate a fully fledged fullstack application built with React, Typescript, and Redux Toolkit including CRUD operations, authentication, routing, pagination, and more.
For more information on how this works with other frontends/backends, head over to the RealWorld repo.
The root of the application is the src/components/App component. The App component uses react-router's HashRouter to display the different pages. Each page is represented by a function component.
Some components include a .slice file that contains the definition of its state and reducers, which might also be used by other components. These slice files follow the Redux Toolkit guidelines. Components connect to the state by using custom hooks.
This application is built following (as much as practicable) functional programming principles:
- Immutable Data
- No classes
- No let or var
- Use of monads (Option, Result)
- No side effects
The code avoids runtime type-related errors by using Typescript and decoders for data coming from the API.
Some components include a .test file that contains unit tests. This project enforces a 100% code coverage.
This project uses prettier and eslint to enforce a consistent code syntax.
src/componentsContains all the functional components.src/components/PagesContains the components used by the router as pages.src/stateContains redux related code.src/servicesContains the code that interacts with external systems (API requests).src/typesContains type definitions alongside the code related to those types.src/configContains configuration files.
This project was bootstrapped with Create React App, using the Redux and Redux Toolkit template.
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.
Note: This project will run the app even if linting fails.
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.