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

igris

v1.0.2

Published

A lightweight, type-safe state management solution designed to make React state simple

Downloads

42

Readme

Igris

Build Size Version Downloads

Igris is a small, simple, and type-safe state management solution for React and React Native. It offers efficient data persistence and seamless integration with various storage mechanisms. Designed to be lightweight and intuitive, Igris helps developers manage application state with ease and confidence.

Features

  • Simple API: Straightforward and intuitive for quick setup and easy state management.
  • Type-safe: Leverages TypeScript to ensure reliable and error-resistant state management.
  • Synchronous & Asynchronous Storage: Flexible options to suit various application requirements.
  • Efficient Data Persistence: Reliable state storage across sessions for seamless user experiences.
  • Customizable Configuration: Adaptable storage and persistence options for diverse application needs.
  • Seamless Integration: Easy to adopt in existing React and React Native projects.

Installation

Install Igris using npm:

npm install igris

Or using yarn:

yarn add igris

Usage

Store Example

import React from 'react';
import { createStore, createState } from 'igris';

// Create a new instance of the store with initial state and actions
export const useCount = createStore(
  { count: 0 },
  ({ set, get }) => ({
    increment: () => set({ count: get().count + 1 }),
    decrement: () => set({ count: get().count - 1 }),
  })
);

// Component using the entire store
const CounterComponent = () => {
  const { count, decrement, increment } = useCount();

  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={increment}>Increment</button>
      <button onClick={decrement}>Decrement</button>
    </div>
  );
};

// Component using a selector for state
const CountDisplayComponent = () => {
  const count = useCount((state) => state.count);
  return <p>Count: {count}</p>;
};

// Component using a selector for actions
const CountActionsComponent = () => {
  const { increment, decrement } = useCount((state) => ({
    increment: state.increment,
    decrement: state.decrement,
  }));

  return (
    <div>
      <button onClick={increment}>Increment</button>
      <button onClick={decrement}>Decrement</button>
    </div>
  );
};

State Example

export const useDarkTheme = createState(true);

const ThemeComponent = () => {
  const [isDark, setDark] = useDarkTheme();

  return (
    <div>
      <p>Current Theme: {isDark ? 'Dark' : 'Light'}</p>
      <button onClick={() => setDark(true)}>DARK</button>
      <button onClick={() => setDark(false)}>LIGHT</button>
    </div>
  );
}

API Reference

createStore(initialState, actions)

Creates a new store with the given initial state and actions.

  • initialState: An object representing the initial state of the store.
  • actions: A function that receives set and get methods and returns an object of actions.

createState(initialValue)

Creates a new state hook with the given initial value.

  • initialValue: The initial value of the state.

Advanced Usage

For comprehensive usage examples and detailed API documentation, please visit our official documentation site.

Contributing

We welcome contributions from the community! If you encounter any issues or have suggestions for improvement, please feel free to open an issue or submit a pull request on the Igris GitHub repository.

Support

If you find Igris helpful, consider supporting its development:

"Buy Me A Coffee"

Your support helps maintain and improve Igris for the entire community.

License

This project is licensed under the MIT License.


Made with ❤️ by Alok Shete