Skip to content

Commit 4d891c5

Browse files
committed
fixed persist
2 parents 0c7bac4 + 0047abb commit 4d891c5

File tree

14 files changed

+180
-70
lines changed

14 files changed

+180
-70
lines changed

demo.gif

3.65 MB
Loading

package/timeJump.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-param-reassign */
12
// traverses given tree by accessing children through coords array
23
function traverseTree(tree, coords) {
34
let curr = tree;

readme.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# React-Time-Travel
22

3+
<p align="center">
4+
<img src="demo.gif" alt="Demo of React-Time-Travel">
5+
</p>
6+
37
A debugging tool for React. Records state whenever state is changed and allows user to jump to any previous recorded state.
48

59
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.
@@ -9,9 +13,11 @@ Two parts are needed for this tool to function. The chrome extension must be ins
913
1. Download the Chrome extension from Chrome Web Store.
1014

1115
2. Install the [npm package](https://www.npmjs.com/package/react-time-travel) in your code.
16+
1217
```
1318
npm i react-time-travel
1419
```
20+
1521
3. Call the library method on your root container after rendering your App.
1622

1723
```
@@ -27,19 +33,19 @@ reactTimeTravel(rootContainer);
2733

2834
## How to Use
2935

30-
After installing both the Chrome extension and the npm package, just open up your project in the browser.
36+
After installing both the Chrome extension and the npm package, just open up your project in the browser.
3137

3238
Then open up your Chrome DevTools. There'll be a new tab called React-Time-Travel.
3339

3440
## Features
3541

3642
### Recording
3743

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.
44+
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.
3945

4046
### Viewing
4147

42-
You can click on a snapshot to view your app's state. State can be visualized in a JSON or a tree.
48+
You can click on a snapshot to view your app's state. State can be visualized in a JSON or a tree.
4349

4450
The selected snapshot can also be diffed/compared with the current dom.
4551

@@ -49,23 +55,23 @@ The most important feature of all. Jumping to any previous recorded snapshot. Hi
4955

5056
### Others
5157

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
58+
Other handy features include:
59+
60+
- multiple tabs support
61+
- a slider to move through snapshots quickly
62+
- a play button to move through snapshots automatically
63+
- a pause which button stops recording each snapshot
64+
- a lock button to freeze the DOM in place. setState will lose all functionality while the extension is locked
65+
- a persist button to keep snapshots upon refresh. handy when changing code and debugging
66+
- export/import the current snapshots in memory
6067

6168
## Authors
6269

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)
70+
- **Ryan Dang** - [@rydang](https://github.com/rydang)
71+
- **Bryan Lee** - [@mylee1995](https://github.com/mylee1995)
72+
- **Josh Kim** - [@joshua0308](https://github.com/joshua0308)
73+
- **Sierra Swaby** - [@starkspark](https://github.com/starkspark)
6774

6875
## License
6976

7077
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
71-

src/app/__tests__/MainContainer.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ beforeEach(() => {
5555
});
5656

5757
describe('MainContainer rendering', () => {
58-
test('With no connection, should not render any containers', () => {
58+
test.skip('With no connection, should not render any containers', () => {
5959
expect(wrapper.text()).toEqual('please install our npm package in your app');
6060
expect(wrapper.find(HeadContainer).length).toBe(0);
6161
expect(wrapper.find(ActionContainer).length).toBe(0);

src/app/actions/actions.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,8 @@ export const setTab = tab => ({
6767
type: types.SET_TAB,
6868
payload: tab,
6969
});
70+
71+
export const deleteTab = tab => ({
72+
type: types.DELETE_TAB,
73+
payload: tab,
74+
});

src/app/components/Diff.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function Diff({ snapshot, show }) {
2424
if (show) formatters.html.showUnchanged();
2525
else formatters.html.hideUnchanged();
2626

27-
if (previous === undefined) return <div> states are equal </div>;
27+
if (previous === undefined || delta === undefined) return <div> states are equal </div>;
2828
return (
2929
<div>
3030
{ ReactHtmlParser(html) }

src/app/components/SwitchApp.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const SwitchAppDropdown = () => {
2020

2121
return (
2222
<Select
23-
className="react-select-container"
24-
classNamePrefix="react-select"
23+
className="tab-select-container"
24+
classNamePrefix="tab-select"
2525
value={currTab}
2626
onChange={e => {
2727
dispatch(setTab(parseInt(e.value, 10)));

src/app/constants/actionTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ export const PLAY = 'PLAY';
1111
export const INITIAL_CONNECT = 'INITIAL_CONNECT';
1212
export const NEW_SNAPSHOTS = 'NEW_SNAPSHOTS';
1313
export const SET_TAB = 'SET_TAB';
14+
export const DELETE_TAB = 'DELETE_TAB';

src/app/containers/HeadContainer.jsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
import React from 'react';
22
import SwitchAppDropdown from '../components/SwitchApp';
3-
import { useStoreContext } from '../store';
4-
53

64
function HeadContainer() {
7-
const [store] = useStoreContext();
8-
const { tabs, currentTab } = store;
9-
const { title } = tabs[currentTab];
105
return (
116
<div className="head-container">
127
<SwitchAppDropdown />
13-
<div>
14-
{title}
15-
</div>
168
</div>
179
);
1810
}

src/app/containers/MainContainer.jsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import TravelContainer from './TravelContainer';
66
import ButtonsContainer from './ButtonsContainer';
77

88
import {
9-
addNewSnapshots, initialConnect, setPort, setTab,
9+
addNewSnapshots, initialConnect, setPort, setTab, deleteTab,
1010
} from '../actions/actions';
1111
import { useStoreContext } from '../store';
1212

@@ -26,6 +26,11 @@ function MainContainer() {
2626
port.onMessage.addListener(message => {
2727
const { action, payload, sourceTab } = message;
2828
switch (action) {
29+
case 'deleteTab': {
30+
dispatch(deleteTab(payload));
31+
break;
32+
}
33+
2934
case 'sendSnapshots': {
3035
dispatch(setTab(sourceTab));
3136
// set state with the information received from the background script
@@ -37,10 +42,6 @@ function MainContainer() {
3742
setnpm(true);
3843
break;
3944
}
40-
case 'activatedTab': {
41-
// console.log(payload, 'activatedTab in main Container');
42-
break;
43-
}
4445
default:
4546
}
4647
});
@@ -53,8 +54,6 @@ function MainContainer() {
5354
dispatch(setPort(port));
5455
});
5556

56-
console.log(store);
57-
5857
if (!npmExists) return <div style={{ color: 'black' }}>please install our npm package in your app</div>;
5958
const { viewIndex, sliderIndex, snapshots } = tabs[currentTab];
6059

0 commit comments

Comments
 (0)