Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

igris

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

igris - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "igris",
"version": "1.0.0",
"version": "1.0.1",
"description": "A small, simple, and type-safe state management solution for React and React Native.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -32,18 +32,22 @@ # Igris

import React from 'react';
import { useAStore, createStore } from 'igris';
import { createStore, createState } from 'igris';
// **Store Example**
// Create a new instance of the store with initial state and actions
const counterStore = createStore(
{ count: 0 }, // Initial state
(setState, getState) => ({
// Callback function to generate actions
increment: () => setState({ count: getState().count + 1 }), // Action to increment count
decrement: () => setState({ count: getState().count - 1 }), // Action to decrement count
export const useCount = createStore(
{ count: 0 },
({ set, get }) => ({
increment: () => {
set({ count: get().count + 1 });
},
decrement: () => {
set({ count: get().count - 1 });
},
})
);
//without selector
// Without selector
const CounterComponent = () => {
const { count, decrement, increment } = useAStore(counterStore);
const { count, decrement, increment } = useCount();

@@ -59,5 +63,5 @@ return (

//with selector get state
// With selector to get state
const CountDisplayComponent = () => {
const count = useAStore(counterStore, (state) => state.count);
const count = useCount((state) => state.count);

@@ -71,9 +75,7 @@ return (

//with selector get actions
// With selector to get actions
const CountActionsComponent = () => {
const increment = useCount((state) => state.increment);
const decrement = useCount((state) => state.decrement);
const increment = useAStore(counterStore, (state) => state.increment);
const decrement = useAStore(counterStore, (state) => state.decrement);
return (

@@ -87,2 +89,17 @@ <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>
);
}
```

@@ -89,0 +106,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc