Skip to content

Commit

Permalink
Add RTKQ infinite query example app (#4744)
Browse files Browse the repository at this point in the history
* Add blank RTK app

* Nuke initial examples

* Add react-router

* Basic routing

* Add msw

* Configure MSW

* Set up MSW

* Use RTK CSB CI build

* Add baseApi

* Add pagination example

* Add react-intersection-observer

* Add infinite scroll example

* Add max-pages example

* Drop local example lockfile

* Drop back to Vite 5 to fix TS issue

* Align Vite versions to fix test TS error
  • Loading branch information
markerikson authored Dec 1, 2024
1 parent aa419c2 commit 0f1db3d
Show file tree
Hide file tree
Showing 31 changed files with 2,329 additions and 8 deletions.
35 changes: 35 additions & 0 deletions examples/query/react/infinite-queries/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"extends": [
"eslint:recommended",
"react-app",
"plugin:react/jsx-runtime",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": { "project": true, "tsconfigRootDir": "./" },
"plugins": ["@typescript-eslint"],
"root": true,
"ignorePatterns": ["dist"],
"rules": {
"@typescript-eslint/consistent-type-imports": [
2,
{ "fixStyle": "separate-type-imports" }
],
"@typescript-eslint/no-restricted-imports": [
2,
{
"paths": [
{
"name": "react-redux",
"importNames": ["useSelector", "useStore", "useDispatch"],
"message": "Please use pre-typed versions from `src/app/hooks.ts` instead."
}
]
}
]
},
"overrides": [
{ "files": ["*.{c,m,}{t,j}s", "*.{t,j}sx"] },
{ "files": ["*{test,spec}.{t,j}s?(x)"], "env": { "jest": true } }
]
}
36 changes: 36 additions & 0 deletions examples/query/react/infinite-queries/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

typesversions
.cache
.yarnrc
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*
*.tgz
4 changes: 4 additions & 0 deletions examples/query/react/infinite-queries/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"semi": false,
"arrowParens": "avoid"
}
27 changes: 27 additions & 0 deletions examples/query/react/infinite-queries/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# vite-template-redux

Uses [Vite](https://vitejs.dev/), [Vitest](https://vitest.dev/), and [React Testing Library](https://github.com/testing-library/react-testing-library) to create a modern [React](https://react.dev/) app compatible with [Create React App](https://create-react-app.dev/)

```sh
npx degit reduxjs/redux-templates/packages/vite-template-redux my-app
```

## Goals

- Easy migration from Create React App or Vite
- As beginner friendly as Create React App
- Optimized performance compared to Create React App
- Customizable without ejecting

## Scripts

- `dev`/`start` - start dev server and open browser
- `build` - build for production
- `preview` - locally preview production build
- `test` - launch test runner

## Inspiration

- [Create React App](https://github.com/facebook/create-react-app/tree/main/packages/cra-template)
- [Vite](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react)
- [Vitest](https://github.com/vitest-dev/vitest/tree/main/examples/react-testing-lib)
14 changes: 14 additions & 0 deletions examples/query/react/infinite-queries/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>React Redux App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
45 changes: 45 additions & 0 deletions examples/query/react/infinite-queries/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "vite-template-redux",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"start": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"test": "vitest run",
"format": "prettier --write .",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"type-check": "tsc --noEmit"
},
"dependencies": {
"@reduxjs/toolkit": "https://pkg.csb.dev/reduxjs/redux-toolkit/commit/aa419c22/@reduxjs/toolkit/_pkg.tgz",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-intersection-observer": "^9.13.1",
"react-redux": "^9.1.0",
"react-router": "^7.0.1"
},
"devDependencies": {
"@testing-library/dom": "^9.3.4",
"@testing-library/jest-dom": "^6.2.0",
"@testing-library/react": "^14.1.2",
"@testing-library/user-event": "^14.5.2",
"@types/react": "^18.2.47",
"@types/react-dom": "^18.2.18",
"@vitejs/plugin-react": "^4.2.1",
"jsdom": "^23.2.0",
"msw": "^2.6.6",
"prettier": "^3.2.1",
"typescript": "^5.3.3",
"vite": "^5.0.0",
"vitest": "^1.2.0"
},
"msw": {
"workerDirectory": [
"public"
]
}
}
Loading

0 comments on commit 0f1db3d

Please sign in to comment.