0.0.8 • Published 4 years ago

react-use-sync v0.0.8

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

react-use-sync

Build Twitter: mehdi_vasigh

React hook for synchronized values between windows

Install

Install with npm:

npm install react-use-sync

Or with yarn:

yarn add react-use-sync

Usage

To sync state between tabs, wrap a React Hook that returns a function with the useState signature (i.e. [value, setValue]).

import React, { useState } from 'react'
import useSync from 'react-use-sync'

function App() {
  const [count, setCount] = useSync('count', useState(0)));
  return (
    <div>
      <p>The count is {count}</p>
      <button onClick={() => setCount(count + 1)}>
        Click me!
      </button>
    </div>
  )
}

Run tests

npm run test

Or:

yarn test

Author

👤 Mehdi Vasigh mehdivasigh@gmail.com

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator

0.0.8

4 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago