2.0.1 • Published 2 years ago

@satha/react-hooks v2.0.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

satha-react-hooks

React hooks for satha (https://satha.netlify.app/)

install satha and satha-react-hooks

// npm
npm i @satha/core @satha/react-hooks

// pnpm
pnpm add @satha/core @satha/react-hooks

useSatha hook

import { useSatha } from "@satha/react-hooks";

Example:

import React from "react";
import { useStorage } from "@satha/core";
import { useSatha } from "@satha/react-hooks";

const App = () => {
  const numbersStore = useStorage("number", 0);
  const [value, setValue] = useSatha(numbersStore);

  const handleAddOne = () => {
    setValue((state) => state + 1);
  };

  return (
    <div>
      <button onClick={handleAddOne}>Add</button>
      <section>{value}</section>
    </div>
  );
};
export default App;