@@ -19,6 +19,7 @@ This is a React-based monitoring and management interface for YDB clusters. The
1919## Critical Bug Prevention Patterns
2020
2121### React Performance (MANDATORY)
22+
2223- ** ALWAYS** use ` useMemo ` for expensive computations, object/array creation
2324- ** ALWAYS** use ` useCallback ` for functions in effect dependencies
2425- ** ALWAYS** memoize table columns, filtered data, computed values
@@ -27,18 +28,19 @@ This is a React-based monitoring and management interface for YDB clusters. The
2728
2829``` typescript
2930// ✅ REQUIRED patterns
30- const displaySegments = useMemo (() =>
31- segments .filter (segment => segment .visible ), [segments ]
32- );
31+ const displaySegments = useMemo (() => segments .filter ((segment ) => segment .visible ), [segments ]);
3332const handleClick = useCallback (() => {
3433 // logic
3534}, [dependency ]);
3635
3736// ✅ PREFER direct callbacks over useEffect
38- const handleInputChange = useCallback ((value : string ) => {
39- setSearchTerm (value );
40- onSearchChange ?.(value );
41- }, [onSearchChange ]);
37+ const handleInputChange = useCallback (
38+ (value : string ) => {
39+ setSearchTerm (value );
40+ onSearchChange ?.(value );
41+ },
42+ [onSearchChange ],
43+ );
4244
4345// ❌ AVOID unnecessary useEffect
4446// useEffect(() => {
@@ -47,11 +49,13 @@ const handleInputChange = useCallback((value: string) => {
4749```
4850
4951### Memory & Display Safety
52+
5053- ** ALWAYS** provide fallback values: ` Number(value) || 0 `
5154- ** NEVER** allow division by zero: ` capacity > 0 ? value/capacity : 0 `
5255- ** ALWAYS** dispose Monaco Editor: ` return () => editor.dispose(); ` in useEffect
5356
5457### Security & Input Validation
58+
5559- ** NEVER** expose authentication tokens in logs or console
5660- ** ALWAYS** validate user input before processing
5761- ** NEVER** skip error handling for async operations
@@ -137,19 +141,17 @@ const handleInputChange = useCallback((value: string) => {
137141
138142``` typescript
139143// ✅ REQUIRED pattern for URL parameters
140- const sortColumnSchema = z
141- .enum ([' column1' , ' column2' , ' column3' ])
142- .catch (' column1' );
144+ const sortColumnSchema = z .enum ([' column1' , ' column2' , ' column3' ]).catch (' column1' );
143145
144146const SortOrderParam: QueryParamConfig <SortOrder []> = {
145- encode : (value ) => value ? encodeURIComponent (JSON .stringify (value )) : undefined ,
146- decode : (value ) => {
147- try {
148- return value ? JSON .parse (decodeURIComponent (value )) : [];
149- } catch {
150- return [];
151- }
152- },
147+ encode : (value ) => ( value ? encodeURIComponent (JSON .stringify (value )) : undefined ) ,
148+ decode : (value ) => {
149+ try {
150+ return value ? JSON .parse (decodeURIComponent (value )) : [];
151+ } catch {
152+ return [];
153+ }
154+ },
153155};
154156```
155157
@@ -159,6 +161,14 @@ const SortOrderParam: QueryParamConfig<SortOrder[]> = {
159161- Time parsing: utilities in ` src/utils/timeParsers/ `
160162- Query utilities: ` src/utils/query.ts ` for SQL/YQL helpers
161163
164+ ## Development Commands
165+
166+ ``` bash
167+ npm run lint # Run all linters before committing
168+ npm run typecheck # TypeScript type checking
169+ npm run unused # Find unused code
170+ ```
171+
162172## Before Making Changes
163173
164174- Run ` npm run lint ` and ` npm run typecheck ` before committing
@@ -173,3 +183,10 @@ const SortOrderParam: QueryParamConfig<SortOrder[]> = {
173183- ` window.api ` - Access API methods in browser console
174184- ` window.ydbEditor ` - Monaco editor instance
175185- Enable request tracing with ` DEV_ENABLE_TRACING_FOR_ALL_REQUESTS `
186+
187+ ## Environment Variables
188+
189+ - ` REACT_APP_BACKEND ` - Backend URL for single-cluster mode
190+ - ` REACT_APP_META_BACKEND ` - Meta backend URL for multi-cluster mode
191+ - ` PUBLIC_URL ` - Base URL for static assets (use ` . ` for relative paths)
192+ - ` GENERATE_SOURCEMAP ` - Set to ` false ` for production builds
0 commit comments