redis like key-value state management solution for React

Overview

jedisdb

redis like key-value state management solution for React

Reactive. Redux alternative. Simple and powerful global state management system, accessible through every component.

Philosophy

jedisdb is a wrapper for React.JS useState hook. jedisdb makes the hook accessible in every component without the need to explicity pass it down or to create stores, actions, and dispatchers.

Features 📋

  1. Reactive
  2. State accessable through every components
  3. no reducer, no action needed
  4. small bundle size

Basic Usage

npm i jedisdb
yarn add jedisdb

happy hacking

import React from 'react'
import useJedis from 'jedisdb'
const Counter = () =>{
/*
if a key is not present in jedis, useJedis('myKey', fallbackValue) will create create that key in jedisdb and then it will return that jedis object,
if key is present it will simply return that jedis object
if we don't pass fallbackValue it will create jedis object with value undefined 
*/
  const counter = useJedis('counter', 0)
  return (
    <div>
      <h1>My counter</h1>
      {counter.state}
      <button onClick={()=>{ counter.state++ }}>+</button>
    </div>
  );
}

Demo:

Counter Codesandbox.

Shopping Cart Codesandbox.

useJedis returns a react hook so it can only used in react functional components,

selectState has no side effects, it can be used anywhere,
createState creates jedis object without any side effects.
demo: Accessing value in JS funciton Codesandbox.

Best Practice

use createState to create jedis object and then use useJedis to access it, is considered best practice

//myGlobalHook.js
//create jedis object
import {createState} from 'jedisdb'
createState({
    theme: 'dark',
    uesrLevel: 'admin',
    counter: 7
})
//app.js
//import jedis object in app
import React from 'react';
import Main from './main';
require('./myGlobalHook')
function App() {
  return (
      <Main />
  );
}
export default App;
{counter.state} ); } export default Counter; ">
//counter.js
//access anywhere
import React from 'react';
import useJedis from "jedisdb";

function Counter() {
  const counter = useJedis('counter') //no need to pass fallback value
  return (
      <>
        {counter.state}
        <button onClick={()=>{ counter.state++ }}>+</button>
      </>
  );
}
export default Counter;

demo: Codesandbox


🤝 Contributing

Contributions, issues and feature requests are welcome! Feel free to check issues page.

Releases(v0.2.4)
The next generation state management library for React

The next generation state management library for React

Bytedance Inc. 150 Sep 18, 2021
Because your state management code should be domain-agnostic.

Because your state management code should be domain-agnostic.

Zachary DeRose 3 Oct 6, 2021
React-Godfather aims to explore an alternative mental model for function components.

React-Godfather "Look ma, no Hooks!" React-Godfather aims to explore an alternative mental model for function components. It adds a thin layer between

John Kapolos 17 Sep 20, 2021
🌊🐷 Utility for generalized composition of React components

???? Utility for generalized composition of React components

Enki 279 Oct 4, 2021
A Fetch Library Support React New Suspense SSR

use-suspense-fetch A data fetching library for React Suspense. inspired by use-asset Feature use LRU Cache support create custom cache support React 1

Snake 6 Jul 12, 2021
📏 A resizable component for React.

?? A resizable component for React.

bokuweb 1.5k Oct 17, 2021
A toy virtual DOM diffing and reconciliation algorithm, with a simple event loop

A toy virtual DOM diffing and reconciliation algorithm, with a simple event loop

Mauro Cano 1 Oct 9, 2021
React-Native library for the WidgetKit framework. Integrate a Widget into your App 🍏📱

react-native-widgetkit React-Native Library for the iOS ?? WidgetKit framework Table of Contents ?? Introduction ??‍?? Installation ??‍ Usage ????‍??

Fasky 82 Oct 13, 2021
A lightweight react library that converts raw HTML to a React DOM structure.

A lightweight react library that converts raw HTML to a React DOM structure.

Arve Knudsen 652 Oct 17, 2021
A component for React that utilizes the Counterpart module to provide multi-lingual/localized text content.

React Translate Component Translate is a component for React that utilizes the Counterpart module and the Interpolate component to provide multi-lingu

Martin Andert 325 Apr 14, 2021
A modern importer written in React

A modern importer written in React

Chris Zhu 31 Oct 8, 2021
HTML to React parser that works on both the server (Node.js) and the client (browser):

HTML to React parser that works on both the server (Node.js) and the client (browser):

Mark 1k Oct 19, 2021
🔌 "Plug and play" for RxJS Observables in React Apps!

"Plug and play" for RxJS Observables in React Apps! npm install @ngneat/react-rxjs useObservable Ever had an Observable holding data that you need to

ngneat 12 Oct 11, 2021
A ReactJS password recovery box component built using the FluentUI library

A ReactJS password recovery box component built using the FluentUI library

Boia Alexandru 2 Sep 20, 2021
📦 noov.js for react ssr solution

?? noov.js for react ssr solution

art-design 17 Jul 13, 2021
A React wrapper for signature pad

react-signature-pad-wrapper A React wrapper for signature pad. Installation This package is available through npm: npm install --save react-signature-

Michael Dzjaparidze 64 Oct 14, 2021
🤖 React Native Android widgets bridged to JS, a proof of concept

React Native Android Widget Proof Of Concept ?? Using React Native and having Android widgets is possible. Create buttons in Java / Android XML to tri

Netbeast 186 Sep 21, 2021
CSS media queries for React

react-media react-media is a CSS media query component for React. A <Media> component listens for matches to a CSS media query and renders stuff based

React Training 2.4k Oct 15, 2021
Utility Components for determining whether elements are in the center of the screen.

@n1ru4l/react-in-center-of-screen Utility Components for determining whether elements are in the center of the screen. Codesandbox Quick Demo: https:/

Laurin Quast 12 May 29, 2021