Skip to content

Commit

Permalink
perf(base): memoize change indicator paths
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoerge committed Apr 28, 2021
1 parent 2b63c91 commit 7a2ffa6
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ export function ChangeIndicatorProvider(props: {
const path = props.path
const focusPath = useMemo(() => props.focusPath || EMPTY_PATH, [props.focusPath])
const parentFullPath = parentContext.fullPath
const fullPath = React.useMemo(() => parentFullPath.concat(path), [parentFullPath, path])
const fullPath = React.useMemo(() => PathUtils.pathFor(parentFullPath.concat(path)), [
parentFullPath,
path,
])

const contextValue = React.useMemo(() => {
return {
Expand Down Expand Up @@ -177,7 +180,7 @@ export const ChangeIndicatorForFieldPath = ({
}) => {
const parentContext = React.useContext(ChangeIndicatorContext)

const fullPath = React.useMemo(() => parentContext.fullPath.concat(path), [
const fullPath = React.useMemo(() => PathUtils.pathFor(parentContext.fullPath.concat(path)), [
parentContext.fullPath,
path,
])
Expand Down Expand Up @@ -206,7 +209,7 @@ export const ChangeIndicatorWithProvidedFullPath = ({
}: any) => {
const parentContext = React.useContext(ChangeIndicatorContext)

const fullPath = React.useMemo(() => parentContext.fullPath.concat(path), [
const fullPath = React.useMemo(() => PathUtils.pathFor(parentContext.fullPath.concat(path)), [
parentContext.fullPath,
path,
])
Expand Down

0 comments on commit 7a2ffa6

Please sign in to comment.