Skip to content

Commit a70d752

Browse files
authored
Merge pull request #7 from oslabs-beta/chris-10-29
changes reflect additional support for context api and hooks
2 parents 4d79271 + e48557d commit a70d752

File tree

6 files changed

+63
-57
lines changed

6 files changed

+63
-57
lines changed

package/linkFiber.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = (snap, mode) => {
3131
const oldSetState = component.setState.bind(component);
3232
// replace component's setState so developer doesn't change syntax
3333
// component.setState = newSetState.bind(component);
34-
component.setState = (state, callback = () => {}) => {
34+
component.setState = (state, callback = () => { }) => {
3535
// don't do anything if state is locked
3636
// UNLESS we are currently jumping through time
3737
if (mode.locked && !mode.jumping) return;
@@ -102,8 +102,8 @@ module.exports = (snap, mode) => {
102102
}
103103
// Check if the component uses hooks
104104
if (
105-
memoizedState &&
106-
Object.hasOwnProperty.call(memoizedState, 'baseState')
105+
memoizedState
106+
&& Object.hasOwnProperty.call(memoizedState, 'baseState')
107107
) {
108108
// Traverse through the currentFiber and extract the getters/setters
109109
astHooks = astParser(elementType);

package/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "reactime",
3-
"version": "2.0.4",
3+
"version": "2.0.9",
44
"description": "A library that helps debug React by memorizing the state of components with every render.",
55
"main": "index.js",
66
"repository": {
@@ -26,9 +26,13 @@
2626
"contributors": [
2727
"Andy Wong",
2828
"Bryan Lee",
29+
"Chris Flannery",
2930
"David Chai",
3031
"Josh Kim",
31-
"Ruthba Anam",
32+
"Prasanna Malla",
33+
"Rajeeb Banstola",
34+
"Rocky Lin",
35+
"Ruth Anam",
3236
"Ryan Dang",
3337
"Sierra Swaby",
3438
"Yujin Kang"
@@ -38,4 +42,4 @@
3842
"acorn": "^7.1.0",
3943
"acorn-jsx": "^5.0.2"
4044
}
41-
}
45+
}

package/readme.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
<p align="center">
2-
<img src ="./assets/readme_logo.png" width="400"/>
2+
<img src ="./assets/readme-logo-svg.svg" width="300"/>
33
</p>
44

5-
# Reactime: A Time Travel Debugger for React
5+
<h1 align="center">State Debugger for React</h1>
66

77
[![GitHub](https://img.shields.io/github/license/oslabs-beta/reactime)](https://github.com/oslabs-beta/reactime)
88
[![Build Status](https://travis-ci.com/oslabs-beta/reactime.svg?branch=master)](https://travis-ci.com/oslabs-beta/reactime)
99
[![npm version](https://badge.fury.io/js/reactime.svg)](http://badge.fury.io/js/reactime)
1010
[![Dependencies](https://david-dm.org/oslabs-beta/reactime.svg)](https://david-dm.org/oslabs-beta/reactime#info=dependencies)
1111
[![DevDependencies](https://david-dm.org/oslabs-beta/reactime/dev-status.svg)](https://david-dm.org/oslabs-beta/reactime?type=dev)
1212
[![Vulnerabilities](https://snyk.io/test/github/oslabs-beta/reactime/badge.svg)](https://snyk.io/test/github/oslabs-beta/reactime)
13-
14-
[![NPM](https://nodei.co/npm/reactime.png)](https://nodei.co/npm/reactime/)
15-
1613
<p align="center">
14+
<a href="https://nodei.co/npm/reactime/"><img src="https://nodei.co/npm/reactime.png"></a>
15+
1716
<img src="demo.gif" alt="Demo of Reactime" style="width: 55%">
1817
</p>
1918

20-
Reactime is a debugging tool for React developers. It records state whenever state is changed and allows user to jump to any previous recorded state.
19+
Reactime is a debugging tool for React developers. It records state whenever it is changed and allows the user to jump to any previously recorded state.
2120

22-
One important thing to note. This devtool is for React apps using only stateful components and prop drilling. If you're using Redux, Hooks, Context, or functional components, this devtool will not function on your app.
21+
This dev tool is for React apps using stateful components and prop drilling, and has beta support for Context API, conditional state routing, Hooks (useState & useEffect) and functional components.
2322

24-
Another thing is that 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.
23+
One thing to note is that this library does not work well when mixing React with direct DOM manipulation.
2524

26-
Two parts are needed for this tool to function. The <a href="https://chrome.google.com/webstore/detail/react-time-travel/cgibknllccemdnfhfpmjhffpjfeidjga">chrome extension</a> must be installed, and the NPM package must be installed and used in the React code.
25+
Two parts are needed for this tool to function. The <a href="https://chrome.google.com/webstore/detail/react-time-travel/cgibknllccemdnfhfpmjhffpjfeidjga"><strong>chrome extension</strong></a> must be installed, and the <a href="https://www.npmjs.com/package/reactime"><strong>NPM package</strong></a> must be installed and used in the React code.
2726

2827
After successfully installing the chrome extension, you can test Reactime functionalities in the demo repositories below.
2928

@@ -63,7 +62,7 @@ Then open up your Chrome DevTools. There'll be a new tab called Reactime.
6362

6463
### Recording
6564

66-
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 Reactime panel.
65+
Whenever state is changed (whenever setState or useState 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 Reactime panel.
6766

6867
### Viewing
6968

@@ -73,14 +72,15 @@ You can click on a snapshot to view your app's state. State can be visualized in
7372

7473
Jumping is the most important feature of all. It allows you to jump to any previous recorded snapshots. Hitting the jump button on any snapshot will change the DOM by setting their state.
7574

76-
### Others
77-
78-
Other handy features include:
75+
### And Much More
7976

77+
- multiple tree graph branches depicting state changes
78+
- tree graph hover functionality to view state changes
79+
- ability to pan and zoom tree graph
8080
- multiple tabs support
8181
- a slider to move through snapshots quickly
8282
- a play button to move through snapshots automatically
83-
- a pause which button stops recording each snapshot
83+
- a pause button, which stops recording each snapshot
8484
- a lock button to freeze the DOM in place. setState will lose all functionality while the extension is locked
8585
- a persist button to keep snapshots upon refresh (handy when changing code and debugging)
8686
- export/import the current snapshots in memory
@@ -91,6 +91,14 @@ Other handy features include:
9191
- **Bryan Lee** - [@mylee1995](https://github.com/mylee1995)
9292
- **Josh Kim** - [@joshua0308](https://github.com/joshua0308)
9393
- **Sierra Swaby** - [@starkspark](https://github.com/starkspark)
94+
- **Ruth Anam** - [@peachiecodes](https://github.com/peachiecodes)
95+
- **David Chai** - [@davidchaidev](https://github.com/davidchaidev)
96+
- **Yujin Kang** - [@yujinkay](https://github.com/yujinkay)
97+
- **Andy Wong** - [@andywongdev](https://github.com/andywongdev)
98+
- **Chris Flannery** - [@chriswillsflannery](https://github.com/chriswillsflannery)
99+
- **Rajeeb Banstola** - [@rajeebthegreat](https://github.com/rajeebthegreat)
100+
- **Prasanna Malla** - [@prasmalla](https://github.com/prasmalla)
101+
- **Rocky Lin** - [@rocky9413](https://github.com/rocky9413)
94102

95103
## License
96104

readme.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
Reactime is a debugging tool for React developers. It records state whenever it is changed and allows the user to jump to any previously recorded state.
2020

21-
This dev tool is for React apps using stateful components and prop drilling, and has beta support for Context API, conditional state routing, Hooks (useState) and functional components.
21+
This dev tool is for React apps using stateful components and prop drilling, and has beta support for Context API, conditional state routing, Hooks (useState, useEffect) and functional components.
2222

2323
One thing to note is that this library does not work well when mixing React with direct DOM manipulation.
2424

@@ -95,6 +95,10 @@ Jumping is the most important feature of all. It allows you to jump to any previ
9595
- **David Chai** - [@davidchaidev](https://github.com/davidchaidev)
9696
- **Yujin Kang** - [@yujinkay](https://github.com/yujinkay)
9797
- **Andy Wong** - [@andywongdev](https://github.com/andywongdev)
98+
- **Chris Flannery** - [@chriswillsflannery](https://github.com/chriswillsflannery)
99+
- **Rajeeb Banstola** - [@rajeebthegreat](https://github.com/rajeebthegreat)
100+
- **Prasanna Malla** - [@prasmalla](https://github.com/prasmalla)
101+
- **Rocky Lin** - [@rocky9413](https://github.com/rocky9413)
98102

99103
## License
100104

src/extension/background.js

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const firstSnapshotReceived = {};
88
// there will be the same number of objects in here as there are reactime tabs open for each user application being worked on
99
const tabsObj = {};
1010

11-
console.log('background scripts');
1211

1312
function createTabObj(title) {
1413
// update tabsObj
@@ -147,9 +146,9 @@ chrome.runtime.onMessage.addListener((request, sender) => {
147146

148147
// Filter out tabs that don't have reactime
149148
if (
150-
action === 'tabReload' ||
151-
action === 'recordSnap' ||
152-
action === 'jumpToSnap'
149+
action === 'tabReload'
150+
|| action === 'recordSnap'
151+
|| action === 'jumpToSnap'
153152
) {
154153
isReactTimeTravel = true;
155154
} else return;
@@ -182,12 +181,10 @@ chrome.runtime.onMessage.addListener((request, sender) => {
182181
tabsObj[tabId].index = 1;
183182

184183
// send a message to devtools
185-
portsArr.forEach(bg =>
186-
bg.postMessage({
187-
action: 'initialConnectSnapshots',
188-
payload: tabsObj,
189-
})
190-
);
184+
portsArr.forEach(bg => bg.postMessage({
185+
action: 'initialConnectSnapshots',
186+
payload: tabsObj,
187+
}));
191188
}
192189
reloaded[tabId] = true;
193190
break;
@@ -202,15 +199,13 @@ chrome.runtime.onMessage.addListener((request, sender) => {
202199
tabsObj[tabId].snapshots.push(request.payload);
203200
sendToHierarchy(
204201
tabsObj[tabId],
205-
new Node(request.payload, tabsObj[tabId])
202+
new Node(request.payload, tabsObj[tabId]),
206203
);
207204
if (portsArr.length > 0) {
208-
portsArr.forEach(bg =>
209-
bg.postMessage({
210-
action: 'initialConnectSnapshots',
211-
payload: tabsObj,
212-
})
213-
);
205+
portsArr.forEach(bg => bg.postMessage({
206+
action: 'initialConnectSnapshots',
207+
payload: tabsObj,
208+
}));
214209
}
215210
break;
216211
}
@@ -223,18 +218,16 @@ chrome.runtime.onMessage.addListener((request, sender) => {
223218
//! INVOKING buildHierarchy FIGURE OUT WHAT TO PASS IN!!!!
224219
sendToHierarchy(
225220
tabsObj[tabId],
226-
new Node(request.payload, tabsObj[tabId])
221+
new Node(request.payload, tabsObj[tabId]),
227222
);
228223
}
229224
// send message to devtools
230225
if (portsArr.length > 0) {
231-
portsArr.forEach(bg =>
232-
bg.postMessage({
233-
action: 'sendSnapshots',
234-
payload: tabsObj,
235-
sourceTab,
236-
})
237-
);
226+
portsArr.forEach(bg => bg.postMessage({
227+
action: 'sendSnapshots',
228+
payload: tabsObj,
229+
sourceTab,
230+
}));
238231
}
239232
break;
240233
}
@@ -247,12 +240,10 @@ chrome.runtime.onMessage.addListener((request, sender) => {
247240
chrome.tabs.onRemoved.addListener(tabId => {
248241
// tell devtools which tab to delete
249242
if (portsArr.length > 0) {
250-
portsArr.forEach(bg =>
251-
bg.postMessage({
252-
action: 'deleteTab',
253-
payload: tabId,
254-
})
255-
);
243+
portsArr.forEach(bg => bg.postMessage({
244+
action: 'deleteTab',
245+
payload: tabId,
246+
}));
256247
}
257248

258249
// delete the tab from the tabsObj
@@ -274,7 +265,6 @@ chrome.runtime.onInstalled.addListener(() => {
274265
// when context menu is clicked, listen for the menuItemId,
275266
// if user clicked on reactime, open the devtools window
276267
chrome.contextMenus.onClicked.addListener(({ menuItemId }) => {
277-
console.log('clicked menu');
278268
const options = {
279269
type: 'panel',
280270
left: 0,

0 commit comments

Comments
 (0)