-
-
Notifications
You must be signed in to change notification settings - Fork 801
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
AutoSizer #5
Comments
If you haven't coded this up yet. I'd pick it up. I've been meaning to try out react-measure. |
Nice! Reach out to Travis (@souporserious). He and I have been talking about this a bit. My latest thinking is that react-window doesn't need an |
I see. Will do. I'll send him an email after I get a bit more familiar with react-measure. I'm kinda curious on how we can measure the parent node or how to pass the |
I was curious about the same thing! Here's what he said about it:
I love the idea of working with Travis on this because (1) this isn't a windowing problem, so it's nice to not have to own it in this library and (2) his approach seems more future looking than the one |
That sounds really promising! I'm going to test out a wrapper component that just calls the I'll post a sandbox |
Oh man, my apostrophe usage 🤦♂️ 💩 @wuweiweiwu glad to hear you're interested! I need to update the rewrite PR with some new code still. I have some time tomorrow night and should be able to get that done. I'd love feedback from either of you if you'd like to help, I'll reach out soon when it's updated so we can hopefully land on good solution 🤞. |
@souporserious Awesome! I look forward to it. I still have to get more familiar with react-measure under the hood :) @bvaughn I make a janky proof of concept that works with some hacky code and a wrapper around |
@wuweiweiwu nice work!!! That's similar to what I was thinking. Just a small note, there's a new API in the works that can be installed under an I threw together a quick sandbox as well here: https://codesandbox.io/s/mzzzz5xmq9 That's wrapping two nodes though so it's not the nicest API. The one problem I'm foreseeing with the
It's not my favorite though 😏 so maybe some |
I'm not sure I see how this example ^ is that different from passing The reasons that seems unfortunate to me are:
|
Yeah, that's similar to what I was thinking. I think I'll stick with the |
@souporserious awesome! please keep me up to date as well :) |
I've used both react-virtualized's |
Hey @techniq love to hear that you're considering I've looked at the |
@souporserious PR would be awesome when you have time. There is a semi-related issue regarding porting more components to use render props (instead of HOCs). Completely understand putting your bill-paying job first, I'm in the same boat 😉 (wish I had more time for open source, and current job doesn't directly support working on it beyond using it to accomplish tasks). |
For the moment, I have published a standalone version of the |
I think I have an issue with Autosizer and VariableSizeList.
and the styles are those
|
@MatteoGioioso I believe the problem is hidden inside your WindowScroll HOC. Without codesandbox with the issue we cannot provide a good help. |
I think not. If I set manually height and width without the Autosizer the WindowScroll works fine. |
Hey @MatteoGioioso 👋 Sorry to hear you're having some trouble with |
@bvaughn Ok, I will do =) |
I'm a heavy user of antD and theyv'e been crying out for virtualization for a long time. I'd like to help them but before i embark, I was just wondering what your current recommendations are for using react window with autosizer, is the react-virtualized-auto-sizer the one you are championing for use with react window for the medium to long term? |
Yes, until/unless there's a standard (Note that souporserious/react-measure is something worth keeping an eye on, but I'm not sure if it's stalled or not.) |
I'm planning on releasing a hooks version for |
I'm currently utilising something that looks like this in the current alpha of React. import { useState, useEffect, Ref } from 'react';
import ResizeObserver from 'resize-observer-polyfill';
const useAutoresize = (elementRef: Ref) => {
const [{ width, height }, setMeasurements] = useState({ width: 0, height: 0 });
const observer = new ResizeObserver(([{ contentRect }]) => {
setMeasurements({ width: contentRect.width, height: contentRect.height });
});
useEffect(
() => {
observer.observe(elementRef.current);
return () => observer.disconnect();
},
[elementRef]
);
return { width, height };
};
export default useAutoresize; |
I'm probably going to attempt to implement AutoSizer for react-window, but if anyone else wants to work on it please do, I can't promise anything |
What do you plan on doing differently than react-virtualized-auto-sizer, @FezVrasta ? |
I released a very lightweight measurement library for React few years ago (400 bytes without any dependency) that works very well (x). I want to use it to create the Specifically, I'd love to provide a Let me know if it makes sense. |
I probably don't want to add anything that isn't specifically about windowing to the base react-window library (including something like auto-sizer). I think it should be an add-on package. I'd like to learn more about how you're using |
This is how it looks like the API we use internally. import { FixedSizeList as List } from 'react-window';
const Row = ({ index, style, updateCellSize }) => {
const [isOpen, setOpen] = useState(false);
return (
<div style={style} tabIndex={0} onClick={() => {
setOpen(isOpen => !isOpen);
updateCellSize();
}}>
Row {index}
{isOpen && 'Lorem lipsum dolor sit amet, the quick brown fox jumps over the lazy dog, woff.}
</div>;
}
}
const Example = () => (
<List
height={150}
itemCount={1000}
itemSize={35}
width={300}
>
{Row}
</List>
); |
I don't think that's a complete enough example. What is |
@bvaughn the
|
|
@bvaughn yeah so, right now we are using react-virtualized. I wanted to contribute here to be able to switch. But I guess I have some confusion in my head 😄 |
I see. Yeah, |
For the time being, I have updated the README to document a solution using |
I am having a problem with auto-sizer when using with react-window variable-sized-grid , it is not working properly with variable-sized-grid. Please provide some solution or example were you have used with auto-sizer with variable-sized-grid. Thanks in advance |
@sgupta317 Try to use AutoSizer component from react-virtualized instead of react-virtualized-auto-sizer. |
Solution: simply wrap it with |
@bvaughn I'm getting two scrollbars when I use React-window list. In react-virualized list, this can be avoided by using autoheight=true. Can you please tell me how to avoid two scrollbars in React-window?
|
Put |
RE using a Resize Observer based auto-sizer, I've got this working using a simple hook based on this example. Seems to be working well so far :) |
@jmrossy Would you be willing to share for us all? :) |
@epurban The hook can be found here: https://github.com/celo-tools/celo-web-wallet/blob/master/src/styles/useResizeObserver.ts#L26 And an example use: |
Document an
AutoSizer
solution built with react-measure (based on the Resize Observer spec, can be polyfilled). This seems like a more future-friendly way of detecting resize.For the moment, I have published a standalone version of the
AutoSizer
component from react-virtualized, as react-virtualized-auto-sizer.The text was updated successfully, but these errors were encountered: