1.2.0 • Published 3 years ago

recoil-logger v1.2.0

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

Recoil-logger

Logger for state manager recoil.

Demo

Example of logs in browser's conosle

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import { RecoilRoot } from "recoil";
import RecoilLogger from 'recoil-logger'

ReactDOM.render(
  <React.StrictMode>
    <RecoilRoot>
      <RecoilLogger />
      <App />
    </RecoilRoot>
  </React.StrictMode>,
  document.getElementById('root')
);

Install

npm install --save-dev recoil-logger

or

yarn add --dev recoil-logger

Now you could add RecoilLogger to your app:

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import { RecoilRoot } from "recoil";
import RecoilLogger from 'recoil-logger'

ReactDOM.render(
  <React.StrictMode>
    <RecoilRoot>
+      <RecoilLogger /> {/* Please add this line inside `RecoilRoot` scope */}
      <App />
    </RecoilRoot>
  </React.StrictMode>,
  document.getElementById('root')
);

After this you can see the events on each atom in browser's console:

Example of logs in browser's conosle

But to see the values you need to add persistence_UNSTABLE key to atom properties:

const counterState = atom({
  key: "count",
  default: 0,
+  persistence_UNSTABLE: {
+    type: 'log'
+  },
});

The key type can has any value but not none (by default it is none).

Example of logs in browser's conosle

Notes

This package use unstable hook useTransactionObservation_UNSTABLE. As far it will be stable the package will be updated with new API.

Demo

$ git clone git@github.com:polemius/recoil-logger.git
$ cd recoil-logger
$ npm install
$ npm run start

Please open localhost:1234

1.2.0

3 years ago

1.1.1

4 years ago

1.1.0

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago