Coder Social home page Coder Social logo

askides / react-plock Goto Github PK

View Code? Open in Web Editor NEW
476.0 5.0 10.0 1.26 MB

The 1kB Masonry Grid for React.

Home Page: https://react-plock-with-nextjs.vercel.app

License: MIT License

JavaScript 0.49% TypeScript 99.51%
react masonry masonry-layout nextjs

react-plock's People

Contributors

askides avatar ramit-mitra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-plock's Issues

Plock grid re-hydration on URL search query change in Next.js, which might cause a delay in onClick events of grid items.

Possible steps to reproduce,

  1. Add an onClick event on the items to update URL search params.
  2. The click event is not working sometimes, It's not consistent though.
  3. Try making the cursor out of focus in the inspector and click directly on the item.
  4. It is recreating the grid on every item click.

Also, there is a delay in Masonry formation, after the DOM hydrates it takes a second to form masonry grid. Is there a config or possible fix?

Longer elements mess up column layouts

When using the Masonry plugin, longer elements disrupt the optimal column layout, causing smaller elements following them to not align correctly. This issue impacts the visual consistency and balance of the layout, especially when displaying content with varying lengths.

Steps to Reproduce

Set up a layout using the Masonry plugin.
Include elements of varying lengths, with some significantly longer than others.
Observe how longer elements affect the layout of smaller elements in subsequent columns.

Expected Behavior

The Masonry plugin should maintain a balanced column layout regardless of the length of individual elements, ensuring that smaller elements are positioned optimally without being impacted by longer ones.

The Value Add

Pretty much all Masonry packages have this issue. If you solve it you are leaps ahead.

Image of issue

image

Build fails on Gatsby project - WebpackError: ReferenceError: window is not defined

Hello,
I am using react-plock for a Gatsby project and it's causing the build to fail.

Definition in package.json,
"react-plock": "^1.1.0",

Error message,
WebpackError: ReferenceError: window is not defined

  • index.js:1
    [ramitmitra.com]/[react-plock]/dist/index.js:1:409

  • index.js:1
    [ramitmitra.com]/[react-plock]/dist/index.js:1:789

  • react.js:35
    [ramitmitra.com]/[fast-deep-equal]/react.js:35:32

  • useCallbackRef.js:28
    [ramitmitra.com]/[@restart]/hooks/esm/useCallbackRef.js:28:18

  • useEventCallback.js:6
    [ramitmitra.com]/[@restart]/hooks/esm/useEventCallback.js:6:1

  • static-entry.js:295
    webpack:/ramitmitra.com/.cache/static-entry.js:295:22

  • useMounted.js:2
    [ramitmitra.com]/[@restart]/hooks/esm/useMounted.js:2:1

Please look into the issue and release a fix. Thank you for the great package and all the hard work.

UseLayoutEffect warning in NextJs

When using this package in NextJs, I get the following warning:

Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used in components that render exclusively on the client. See https://reactjs.org/link/uselayouteffect-ssr for common fixes.

Any chance for SSR support?

Breakpoints with Gap setting

I wonder if it would be possible to add the ability to use different gap values using the same "breakpoint" method as the columns?

Plock images in rows

Hi,

Thank you for this fantastic library. Are we able to plock images in rows?

Error importing jsx-runtime

I get this error using nextJs:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '~/node_modules/react/jsx-runtime' imported from ~/node_modules/react-plock/index.js
Did you mean to import react/jsx-runtime.js?

The automated release is failing 🚨

🚨 The automated release from the next branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the next branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two Factor Authentication for your account, set its level to "Authorization only" in your account settings. semantic-release cannot publish with the default "
Authorization and writes" level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Flickering issue on initial render

This is a great lightweight package. But the package is currently set a default columns and gap to 1, which on Next.js it results to flickering on initial render.

const [values, setValues] = React.useState({ columns: 1, gap: 1 });

Will you consider adding additional support to use User-Agent header as a proxy to set the default columns and gap if it's available to minimise the flicker, then having useEffect to update once the window object is available?

Possibile to get the real index (idx) ?

Hello,

is it possible to get the real index in the render ?

const items = [...imageUrls];

  return (
    <Masonry
      items={items}
      config={{
        columns: [1, 2, 3],
        gap: [24, 12, 6],
        media: [640, 768, 1024],
      }}
      render={(item, idx) => (
        <img key={idx} src={item} style={{ width: "100%", height: "auto" }} />
      )}
    />
  );

Here idx is the number of the row, is there a proper clean way to know that I am displaying third item ? Like "index" in a map.

Thank you, and thanks a lot for your work

Error when doing `npm install` for most recent React version

Description

When running npm install react-plock I get the following error:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^18.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"18.1.0" from [email protected]
npm ERR! node_modules/react-plock
npm ERR!   react-plock@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

I'm currently on version 18.2.0 of React which is why this is erroring. I believe to fix this, the related dependencies just need to be updated.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.