Skip to content
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

useScrollStates hook created replacing direct access to scrollTopState & scrollLeftState #4938

Closed
wants to merge 5 commits into from

Conversation

Jeetch8
Copy link
Contributor

@Jeetch8 Jeetch8 commented Apr 12, 2024

Hii , I have made the changes. Can you please check and give me a feedback on that ?
As I am a bit uncertain on it.
here is the issue #4826
Thank u

Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Jeetch8, thank you for your work! I have left some guidance on how to use hooks and component States. The doc is inexistant about it for now but I can guide you more if needed

import { extractComponentState } from "@/ui/utilities/state/component-state/utils/extractComponentState"
import { ViewScopeInternalContext } from "@/views/scopes/scope-internal-context/ViewScopeInternalContext";

export const useScrollStates = (scrollWrapperId?:string) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in the filename that should be useScrollStates

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you move this hook into a internal subfolder within hooks. internal hooks cannot be used outside of their component (here Scroll / ScrollWrapper).
This allows us to narrow down the public API of a component to enforce interface (easy maintenance).

We will need to create another useScrollTopValue(scrollWraperId) and useScrollLeftValue(scrollWraperId) hooks. These hooks will only expose what functions we want it to expose.

Here we would for example only want to expose the getter: useRecoilValue(scrollLeftState) (scrollLeftState being imported from useScrollStates)

Then from ColumnHead, Recordtable, RecordTableHeaderCell you can use useScrollTopValue and useScrollLeftValue

@charlesBochet
Copy link
Member

Also, make sure to run yarn nx lint:ci twenty-front before pushing!

@FelixMalfait
Copy link
Member

Hey, I'm sorry I will close this since it hasn't move since the last comments a month ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants