Skip to content

Commit 46c9fa4

Browse files
authored
Merge pull request #3086 from warjiang/feat/devtools
frontend: enable devtools according to environment
2 parents 2eb3232 + 07eb68e commit 46c9fa4

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

docs/development/frontend.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ make run-frontend
2727
This command leverages the `create-react-app`'s start script that launches
2828
a development server for the frontend (by default at `localhost:3000`).
2929

30+
We use [react-query](https://tanstack.com/query/latest/docs/framework/react/overview)
31+
for network request, if you need the devtools for react-query, you can simply set `REACT_APP_ENABLE_REACT_QUERY_DEVTOOLS=true` in the `.env` file.
32+
3033
## API documentation
3134

3235
API documentation for TypeScript is done with [typedoc](https://typedoc.org/) and [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown), and is configured in tsconfig.json

frontend/make-env.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const envContents = {
1010
REACT_APP_HEADLAMP_VERSION: appInfo.version,
1111
REACT_APP_HEADLAMP_GIT_VERSION: gitVersion,
1212
REACT_APP_HEADLAMP_PRODUCT_NAME: appInfo.productName,
13+
REACT_APP_ENABLE_REACT_QUERY_DEVTOOLS: 'false'
1314
};
1415

1516
function createEnvText() {

frontend/src/App.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ const queryClient = new QueryClient({
4343
},
4444
},
4545
});
46-
const queryDevtoolsEnabled = false;
46+
47+
// https://vite.dev/guide/env-and-mode
48+
// if you want to enable the devtools for react-query,
49+
// just set REACT_APP_ENABLE_REACT_QUERY_DEVTOOLS=true in .env file
50+
const queryDevtoolsEnabled = import.meta.env.REACT_APP_ENABLE_REACT_QUERY_DEVTOOLS === 'true';
4751

4852
function App() {
4953
return (

0 commit comments

Comments
 (0)