npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

my-react-sortable

v1.1.4

Published

my-react-sortable module helps you create React sortable lists easily. Where you can re-arrange the list items.

Downloads

24

Readme

my-react-sortable

my-react-sortable module helps you create React sortable lists easily. Where you can re-arrange the list items.

There are 2 components in the module SortableList and SortableCard

Import and Usage -

import { SortableList, SortableCard } from 'my-react-sortable'
// ...
  const [ list, setList ] = useState(initialList)
// ...
  <SortableList
    list={list}
    setList={setList}
  >
   {list.map(listItem => (
      <SortableCard
        key={listItem.id}
      >
        {/* Card content */}
      </SortableCard>
    ))}
  </SortableList>

List of props for SortableList -

  • list - the react state where you are storing the list* (required) (Array)
  • setList - the function to set the list state* (required) (Function)
  • horizontalList - if the list is being displayed horizontally(e.g.display: flex;). Then you should also pass this prop. (Boolean)
  • customStyle - this prop can be used to apply your own custom styles on the SortableList component. Just write the css styles in a string variable like const myStyle = "background-color: #aeaeae; border-radius: 0.5rem;", and pass that as optional customStyle prop (style will be applied using styled-components) (String)

NOTE - If you are using class based component, you can make a setList function like this to pass as setList prop -

  setList = (newList) => {
    if (typeof newList === 'function') {
      this.setState(prevState => ({ list: newList(prevState.list) }))
    } else {
      this.setState({ list: newList })
    }
  }

List of props for SortableCard -

  • customStyle - Same usage as SortableList, can be used to define your own styles on SortableCard component (String)

Modules used -

  • react
  • styled-components