react-virtualized icon indicating copy to clipboard operation
react-virtualized copied to clipboard

How to rerender a masonry component when an event is triggered?

Open zendevil opened this issue 3 years ago • 1 comments

I would like to rerender the whole masonry component when a specific event is triggered in the app. How can I do that?

zendevil avatar Jan 18 '22 19:01 zendevil

@zendevil use a state flag to optionally render the component. Have your event toggle the flag.

Roughly:

export default (props) => {
  const [showMasonryView, setShowMasonryView] = useState(false);
  

  return (
    <div>
     <div>Whatever else is on your page</div>
     <button onClick={() => setShowMasonryView(curr => !curr)}>Toggle View</button>
      {showMasonryView && <YourMasonryComponent/>}
    <div>
  );
}

HarrisonJackson avatar Feb 16 '22 00:02 HarrisonJackson