@egjs/react-infinitegrid
TypeScript icon, indicating that this package has built-in type declarations

4.11.1 • Public • Published

InfiniteGrid Logo
@egjs/react-infinitegrid

npm bundle size (scoped) GitHub commit activity npm downloads per month GitHub contributors GitHub

A React component that can arrange items infinitely according to the type of grids

Demo / Documentation / Other components

⚙️ Installation

npm install --save @egjs/react-infinitegrid

🏃 Quick Start

import * as React from "react";
import { MasonryInfiniteGrid } from "@egjs/react-infinitegrid";

function getItems(nextGroupKey: number, count: number) {
  const nextItems = [];
  const nextKey = nextGroupKey * count;

  for (let i = 0; i < count; ++i) {
    nextItems.push({ groupKey: nextGroupKey, key: nextKey + i });
  }
  return nextItems;
}

const Item = ({ num }: any) => <div className="item">...</div>;

export default function App() {
  const [items, setItems] = React.useState(() => getItems(0, 10));

  return <MasonryInfiniteGrid
    className="container"
    gap={5}
    onRequestAppend={(e) => {
      const nextGroupKey = (+e.groupKey! || 0) + 1;

      setItems([
        ...items,
        ...getItems(nextGroupKey, 10),
      ]);
    }}
  >
    {items.map((item) => <Item data-grid-groupkey={item.groupKey} key={item.key} num={item.key} />)}
  </MasonryInfiniteGrid>;
}

🙌 Contributing

See CONTRIBUTING.md.

📝 Feedback

Please file an Issue with label "React".

📜 License

egjs-infinitegrid is released under the MIT license.

Copyright (c) 2015-present NAVER Corp.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

      

Package Sidebar

Install

npm i @egjs/react-infinitegrid

Weekly Downloads

3,750

Version

4.11.1

License

MIT

Unpacked Size

98.1 kB

Total Files

28

Last publish

Collaborators

  • anuu0916
  • braixen
  • ajaxpf
  • jongmoon
  • sculove
  • happyhj
  • mixed
  • netil
  • younkue
  • woodneck