-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Reworked types and rendering to try and reduce needless renders (…
- Loading branch information
1 parent
7d9b95a
commit 74e3a19
Showing
19 changed files
with
158 additions
and
99 deletions.
There are no files selected for viewing
Binary file modified
BIN
-157 Bytes
(100%)
frontend/__snapshots__/scenes-app-notebooks--recordings-playlist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { useValues } from 'kea' | ||
import { FEATURE_FLAGS } from 'lib/constants' | ||
import { featureFlagLogic } from 'lib/logic/featureFlagLogic' | ||
|
||
export const useFeatureFlag = (flag: keyof typeof FEATURE_FLAGS): boolean => { | ||
const { featureFlags } = useValues(featureFlagLogic) | ||
|
||
return !!featureFlags[FEATURE_FLAGS[flag]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { useMemo, useRef } from 'react' | ||
import { useFeatureFlag } from './useFeatureFlag' | ||
|
||
export function useWhyDidIRender(name: string, props: Record<string, any>): void { | ||
const oldProps = useRef<Record<string, any>>() | ||
const logRenderInfo = useFeatureFlag('DEBUG_REACT_RENDERS') | ||
|
||
useMemo(() => { | ||
if (!logRenderInfo) { | ||
return | ||
} | ||
|
||
if (oldProps.current) { | ||
const oldChangedProps = Object.keys(oldProps.current).filter((key) => !(key in props)) | ||
const changedProps = Object.keys(props).filter((key) => props[key] !== oldProps.current?.[key]) | ||
|
||
if (changedProps.length > 0) { | ||
// eslint-disable-next-line no-console | ||
console.log(`${name} props changed:`, [...oldChangedProps, ...changedProps]) | ||
} | ||
} | ||
oldProps.current = props | ||
}, [Object.values(props)]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.