question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Suggestion] Expose onItemsRendered value as props to rendered cells

See original GitHub issue

I have a specific use-case*, that i need to know the value that i would get from onItemsRendered The thing is, the onItemsRendered callback is called only after the items was rendered.

I assume that, when render calls are made to render cells, the library already knows the values it will pass to onItemsRendered. as it uses them to calculate which cells to render.

So, the lib can pass it as an additional prop to the cell component.

  • My use case is: I’m trying to build a grid with fixed header, footer, and left-most visual column.

Code example of what i need: https://github.com/bvaughn/react-window/compare/master...Bnaya:iterations?expand=1 I’n going to try and see if its helps me

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
bvaughncommented, Jun 2, 2019

Aside of that, i still think its possible to implement areEqual is way that ignores overscan…Index values and treats them as never changed, but the developer can opt-in to it.

It could be implemented that way, but I’m not comfortable wit treating something that changes as though it doesn’t change. I think it could lead to broken/unexpected behavior. The reason this is okay with style is that it only changes shallowly but that would not be the case with the indices you’re describing.

I think we’re going in a circles a little at this point. 😄 If you’d like to create a PR for me to consider, I will make time to look at it. (Can’t promise it will be merged, but I will look at it.)

0reactions
Bnayacommented, Jun 2, 2019

My goal: I need to give special behaviour to the first and last rendered cells vertical and horizontal. The way i can tell that a cell is first/last is comparing item.rowIndex === item.itemsRenderedCallbackParams.overscanRowStartIndex

The idea is: even tho cell X,Y is changing, rowIndex === overscanRowStartIndex, I give it a named key, first-in-column:first-in-row, first-in-column:1-in-row etc. That’s only if its a “special” cell. And that’s how react uses the same DOM element even that the X,Y is different.

Let’s say i don’t have overscanRowStartIndex data as props, i can play with the key to force re-mount my edges cells by adding also x and y to the named key, something like: first-in-column-4:first-in-row-5. it will be less performant for me, but i think its reasonable.

Please see my itemKeyProvider: https://github.com/Bnaya/sticky-eurovision/blob/master/src/implementations/WithReactWindowAndSticky/WithReactWindowAndSticky.tsx#L50-L86 itemKey I hope it will be more clear

Aside of that, i still think its possible to implement areEqual is way that ignores overscan...Index values and treats them as never changed, but the developer can opt-in to it. Something like:

export default function areEqual(
  prevProps: Object,
  nextProps: Object
): boolean {
  const { overScanInfo: prevOverScanInfo, style: prevStyle, ...prevRest } = prevProps;
  const { overScanInfo: nextOverScanInfo, style: nextStyle, ...nextRest } = nextProps;

  // we don't care about you by default!!! 
  // shallowDiffers(prevOverScanInfo, nextOverScanInfo)

  return (
    !shallowDiffers(prevStyle, nextStyle) && !shallowDiffers(prevRest, nextRest)
  );
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Visual Guide to React Rendering - Props - Alex Sidorenko
Let's try to pass a primitive value as a prop to the Child. The Child is wrapped in memo . This means it...
Read more >
@elastic/eui | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
React hooks for headless table components - Morioh
This is the main hook exposed by the library and should be your entrypoint for any table functionality. Only columns and data are...
Read more >
Source - GitHub
This prop lets the consumer render a hint below the search bar that will be ... to `useEuiTheme`'s return value, supporting React's shallow...
Read more >
@elastic/eui: Versions | Openbase
Added the customQuickSelectRender render prop to EuiSuperDatePicker ... when the search bar is controlled and cleared using searchProps.value (#6317) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found