Skip to content

Replace rowGetter and rowsCount with rows[] #1869

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

Merged
merged 9 commits into from
Jan 13, 2020
Merged

Replace rowGetter and rowsCount with rows[] #1869

merged 9 commits into from
Jan 13, 2020

Conversation

nstepien
Copy link
Contributor

@nstepien nstepien commented Jan 9, 2020

I think rowGetter is an antipattern: if rowGetter never changes, then it will hide row updates, and might prevent rerenders in memoized components/useMemo.

The downside is that users will now need to load all the rows at once.
We're also updating rdg to leave value access to the formatter/editor implementations, so not all data needs to be computed upfront.
I wonder if we even need row objects at all! Formatters and editors could just load the row data with only the row index. But then how do we trigger cells rerendering?
Alternatively, users could use a Proxy on rows or as row objects. 🤔

WDYT?

@nstepien nstepien requested a review from amanmahajan7 January 9, 2020 15:00
@nstepien nstepien self-assigned this Jan 9, 2020
@qili26
Copy link
Contributor

qili26 commented Jan 10, 2020

@nstepien

The downside is that users will now need to load all the rows at once.

I don't think this is an issue as we can use endless scrolling to call API to pull the new data. #1854 If it's for memory consideration for huge data set, maybe the dev should just implement the pagination.

I wonder if we even need row objects at all! Formatters and editors could just load the row data with only the row index. But then how do we trigger cells rerendering?

If we pass the row idx / column idx only, then probably we have to discard the React.Memo in row / cell level inside RDG, so that they will always re-render. However, I guess that's not a feasible approach.

Alternatively, users could use a Proxy on rows or as row objects.

Looks like Proxy is not IE 11 friendly. However, just out of curiosity, could you extend a little bit like how you would use it?

@nstepien
Copy link
Contributor Author

could you extend a little bit like how you would use it?

Something like that:

const rowsProxy = new Proxy({}, {
  get(obj, prop) {
    if (prop === 'length') return rowsCount;
    return rowGetter(Number(prop));
  }
});

return <DataGrid rows={rowsProxy} />;

@nstepien nstepien changed the title Replace rowGetter and rowsCount with rows Replace rowGetter and rowsCount with rows[] Jan 10, 2020
Copy link
Contributor

@amanmahajan7 amanmahajan7 left a comment

Choose a reason for hiding this comment

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

LGTM. I think for lazy loading we can now just use the onScroll prop. Let's wait for @qili26 to review this PR as well

@amanmahajan7
Copy link
Contributor

Nm, just realized he has already approved it

@amanmahajan7 amanmahajan7 merged commit 590cafa into pre-canary Jan 13, 2020
@amanmahajan7 amanmahajan7 deleted the rows branch January 13, 2020 13:36
@ShantanuNair
Copy link

LGTM. I think for lazy loading we can now just use the onScroll prop. Let's wait for @qili26 to review this PR as well

Has the onScroll feature been merged into canary or pre-canary yet? #1854 hasn't been merged in yet as far as I'm aware.

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

Successfully merging this pull request may close these issues.

4 participants