This client-side app demonstrates the features of the experimental React in the context of the real app with the help of Experimental React Router v6 and React Query with Suspense enabled.
- Implementing the render-as-you-fetch pattern. During route transitions the app is configured to load the code and data for new routes in parallel. It uses the new prop of the Route,Beta React router component, called "preload" which will be invoked before the Component renders.
- Using Concurrent Mode and Suspense to improve the loading sequence, including
useTransition()
for route transitions in order to continue showing the previous route for a brief period while the next route is prepared/rendered. - Uses the Suspense-enabled React query to colocate data-deps.
- Uses some features from React Router v6 like preloading, nested routes, relative links, hook for Search params, etc.
This app is meant for experimentation; we recommend cloning and running locally, hacking on the source code, trying to change things and see how it affects the user experience.
-
First, clone the app:
git clone [email protected]:denniscual/simple-mock-github.git
-
Change into the app's directory:
cd simple-mock-github
-
Install the app's dependencies:
# npm users: npm install # yarn users: yarn
-
Get your GitHub authentication token in order to let the app query GitHub's public GraphQL API:
-
Ensure that at least the
repo
scope is selected. -
Generate the token
-
Create a file
./simple-mock-github/.env.local
and add the following contents (substitute<TOKEN>
for your authentication token):# simple-mock-github/.env.local REACT_APP_GITHUB_AUTH_TOKEN=<TOKEN>
Now you're ready to run the app!
You can run the app by navigating to simple-mock-github/issue-tracker/
and then running the start command:
# npm users:
npm start
# yarn users:
yarn start
This will start the development server and open a browser to http://localhost:3000/facebook/react/code.
This app uses a number of technologies and references:
- Create React App:
- The app uses typescript template.
- The app uses CRA's support for environment variables - https://create-react-app.dev/docs/adding-custom-environment-variables - to allow configuring the GitHub authentication token.
- The app enables prettier for code formatting, as discussed in https://create-react-app.dev/docs/setting-up-your-editor#formatting-code-automatically.
- Note that Create React App itself builds upon many great technologies, see the docs for more details!
- React's experimental release with Concurrent Mode and Suspense.
- Experimental React Router v6 . This version already support the
preloading
of data and codes. - React Query Suspense-enabled.
- Experimental Stitches - The modern styling library.
- Restatum - Simple state management library.
- Relay Issue Tracker Example