https://github.com/timdorr/react-log-state
https://github.com/timdorr/react-log-state
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/timdorr/react-log-state
- Owner: timdorr
- Created: 2016-08-12T01:55:46.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2020-04-01T10:57:57.000Z (about 6 years ago)
- Last Synced: 2025-05-05T03:41:58.636Z (about 1 year ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 24
- Watchers: 1
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# React Log State [![npm package][npm-badge]][npm]
[npm-badge]: https://img.shields.io/npm/v/react-log-state.svg?style=flat-square
[npm]: https://www.npmjs.org/package/react-log-state
A little tweak on [@ryanflorence](https://github.com/ryanflorence)'s [React Lumberjack](https://github.com/ryanflorence/react-lumberjack). Lets you track setState calls on React elements at runtime.

## Setup
#### [npm](https://www.npmjs.com)
Install package:
```
npm install react-log-state
```
And include in your code:
```js
require('react-log-state')
```
#### `` tag
Add the following to your HTML anywhere:
```html
<script src="https://npmcdn.com/react-log-state">
```
## Usage
Open up your browser's console. Select an element using the [React DevTools](https://github.com/facebook/react-devtools) (which makes it available on the `$r` variable). Then activate logging:
```js
ReactLogState($r)
```
That's it! Any calls to `setState` will be logged in the console.
---
You can also hook into all `setState` calls globally:
```js
ReactLogState.logAll()
```
Of course, this technically alters how `setState` operates, so you may have a bad time if any of your components making a lot of changes to state.