-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CB-4541 refactor: tree #2326
CB-4541 refactor: tree #2326
Conversation
|
||
return ( | ||
<div ref={mountOptimization.setRootRef} style={{ overflow: 'auto', position: 'relative' }}> | ||
<NodeSizeCacheContext.Provider value={elementsSizeCache}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this amount of contexts scares me. at this point we should think how it would affect amount of rerenders in the tree
const [nodeCache] = useState( | ||
() => | ||
new MetadataMap<string, IComputedValue<INode>>(id => | ||
computed(() => applyTransforms(id, options.getNode(id), [rootNodeTransformer(options.rootId), ...(options.nodeTransformers || [])])), | ||
), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is hard to undestand. please decompose it a little bit
const [childrenCache] = useState( | ||
() => | ||
new MetadataMap<string, IComputedValue<string[]>>(id => | ||
computed(() => applyTransforms(id, options.getChildren(id), options.childrenTransformers)), | ||
), | ||
); | ||
const [stateCache] = useState( | ||
() => | ||
new MetadataMap<string, IComputedValue<INodeState>>(id => | ||
computed(() => applyTransforms(id, state.getState(id), [rootNodeStateTransformer(options.rootId), ...(options.stateTransformers || [])])), | ||
), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
}, | ||
}), | ||
{ state: observable.ref, rootId: observable.ref }, | ||
{ state, rootId: options.rootId }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not a pure function. please add here some deps so all functions uses this
operator instead of get what it need outside of this scope
return useObservableRef( | ||
() => ({ | ||
getState(id: string): Readonly<INodeState> { | ||
return state.get(id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.state
|
||
this.element = element; | ||
if (element) { | ||
this.observer = new ResizeObserver(this.handleResize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one needs to be tested manually. cause as far as I remember resizeobserver
can track only one axis. wether is width or height (dont remember which one). if it is important to track both I would recommend to use addEventListener('resize', this.handleResize)
No description provided.