|
| 1 | +# React-Time-Travel |
| 2 | + |
| 3 | +A debugging tool for React. Records state whenever state is changed and allows user to jump to any previous recorded state. |
| 4 | + |
| 5 | +Two parts are needed for this tool to function. The chrome extension must be installed, and the NPM package must be installed and used in the React code. |
| 6 | + |
| 7 | +## Installing |
| 8 | + |
| 9 | +1. Download the Chrome extension from Chrome Web Store. |
| 10 | + |
| 11 | +2. Install the [npm package](https://www.npmjs.com/package/react-time-travel) in your code. |
| 12 | +``` |
| 13 | +npm i react-time-travel |
| 14 | +``` |
| 15 | +3. Call the library method on your root container after rendering your App. |
| 16 | + |
| 17 | +``` |
| 18 | +const reactTimeTravel = require('react-time-travel'); |
| 19 | +
|
| 20 | +const rootContainer = document.getElementById('root'); |
| 21 | +ReactDom.render(<App />, rootContainer); |
| 22 | +
|
| 23 | +reactTimeTravel(rootContainer); |
| 24 | +``` |
| 25 | + |
| 26 | +4. Done! That's all you have to do to link your React project to our library. |
| 27 | + |
| 28 | +## How to Use |
| 29 | + |
| 30 | +After installing both the Chrome extension and the npm package, just open up your project in the browser. |
| 31 | + |
| 32 | +Then open up your Chrome DevTools. There'll be a new tab called React-Time-Travel. |
| 33 | + |
| 34 | +## Features |
| 35 | + |
| 36 | +### Recording |
| 37 | + |
| 38 | +Whenever state is changed (whenever setState is called), this extension will create a snapshot of the current state tree and record it. Each snapshot will be displayed in Chrome DevTools under the React-Time-Travel panel. |
| 39 | + |
| 40 | +### Viewing |
| 41 | + |
| 42 | +You can click on a snapshot to view your app's state. State can be visualized in a JSON or a tree. |
| 43 | + |
| 44 | +The selected snapshot can also be diffed/compared with the current dom. |
| 45 | + |
| 46 | +### Jumping |
| 47 | + |
| 48 | +The most important feature of all. Jumping to any previous recorded snapshot. Hitting the jump button on any snapshot will change the dom by setting their state. One important thing to note. This library does not work well when mixing React with direct DOM manipulation. Since DOM manipulation doesn't change any React state, this library cannot record or even detect that change. Of course, you should be avoiding mixing the two in the first place. |
| 49 | + |
| 50 | +### Others |
| 51 | + |
| 52 | +Other handy features include: |
| 53 | +* multiple tabs support |
| 54 | +* a slider to move through snapshots quickly |
| 55 | +* a play button to move through snapshots automatically |
| 56 | +* a pause which button stops recording each snapshot |
| 57 | +* a lock button to freeze the DOM in place. setState will lose all functionality while the extension is locked |
| 58 | +* a persist button to keep snapshots upon refresh. handy when changing code and debugging |
| 59 | +* export/import the current snapshots in memory |
| 60 | + |
| 61 | +## Authors |
| 62 | + |
| 63 | +* **Ryan Dang** - [@rydang](https://github.com/rydang) |
| 64 | +* **Bryan Lee** - [@mylee1995](https://github.com/mylee1995) |
| 65 | +* **Josh Kim** - [@joshua0308](https://github.com/joshua0308) |
| 66 | +* **Sierra Swaby** - [@starkspark](https://github.com/starkspark) |
| 67 | + |
| 68 | +## License |
| 69 | + |
| 70 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details |
0 commit comments