Skip to content

Commit d73f38d

Browse files
committed
update readme for concurrent mode support
1 parent ee15ef9 commit d73f38d

File tree

4 files changed

+53
-40
lines changed

4 files changed

+53
-40
lines changed

package/astParser.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ module.exports = elementType => {
3131
}
3232
});
3333

34-
/* body will look something like:
35-
[ 0: "_useState"
36-
1: "_useState2"
37-
2: "character"
38-
3: "setCharacter" ]
39-
*/
40-
4134
// Iterate array and determine getter/setters based on pattern
4235
statements.forEach((el, i) => {
4336
if (el.match(/_use/)) hookState[el] = statements[i + 2];

package/linkFiber.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = (snap, mode) => {
3333
const oldSetState = component.setState.bind(component);
3434
// replace component's setState so developer doesn't change syntax
3535
// component.setState = newSetState.bind(component);
36-
component.setState = (state, callback = () => { }) => {
36+
component.setState = (state, callback = () => {}) => {
3737
// don't do anything if state is locked
3838
// UNLESS we are currently jumping through time
3939
if (mode.locked && !mode.jumping) return;
@@ -72,7 +72,8 @@ module.exports = (snap, mode) => {
7272
let index = 0;
7373
astHooks = Object.values(astHooks);
7474
// while memoizedState is truthy, save the value to the object
75-
while (memoizedState && memoizedState.queue) { // prevents useEffect from crashing on load
75+
while (memoizedState && memoizedState.queue) {
76+
// prevents useEffect from crashing on load
7677
// if (memoizedState.next.queue === null) { // prevents double pushing snapshot updates
7778
changeUseState(memoizedState);
7879
// }
@@ -89,7 +90,6 @@ module.exports = (snap, mode) => {
8990
function createTree(currentFiber, tree = new Tree('root')) {
9091
if (!currentFiber) return tree;
9192

92-
9393
const {
9494
sibling,
9595
stateNode,
@@ -109,7 +109,10 @@ module.exports = (snap, mode) => {
109109
// Check if the component uses hooks
110110
// console.log("memoizedState", memoizedState);
111111

112-
if (memoizedState && Object.hasOwnProperty.call(memoizedState, 'baseState')) {
112+
if (
113+
memoizedState &&
114+
Object.hasOwnProperty.call(memoizedState, 'baseState')
115+
) {
113116
// 'catch-all' for suspense elements (experimental)
114117
if (typeof elementType.$$typeof === 'symbol') return;
115118
// Traverse through the currentFiber and extract the getters/setters
@@ -157,7 +160,7 @@ module.exports = (snap, mode) => {
157160
_reactRootContainer: { _internalRoot },
158161
_reactRootContainer,
159162
} = container;
160-
// only assign internal rootp if it actually exists
163+
// only assign internal root if it actually exists
161164
fiberRoot = _internalRoot || _reactRootContainer;
162165
}
163166

readme.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
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+
1314
<p align="center">
1415
<a href="https://nodei.co/npm/reactime/"><img src="https://nodei.co/npm/reactime.png"></a>
1516

@@ -18,7 +19,7 @@
1819

1920
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.
2021

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.
22+
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.
2223

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

@@ -42,15 +43,25 @@ npm i reactime
4243
3. Call the library method on your root container after rendering your App.
4344

4445
```
45-
const reactime = require('reactime');
46+
import reactime from 'reactime';
4647
4748
const rootContainer = document.getElementById('root');
4849
ReactDOM.render(<App />, rootContainer);
4950
5051
reactime(rootContainer);
5152
```
5253

53-
4. Done! That's all you have to do to link your React project to our library.
54+
4. For experimental concurrent mode support:
55+
56+
```
57+
import reactime from 'reactime';
58+
59+
const rootContainer = ReactDOM.createRoot( document.getElementById('root'));
60+
rootContainer.render(<App />);
61+
reactime(rootContainer);
62+
```
63+
64+
5. Done! That's all you have to do to link your React project to our library.
5465

5566
## How to Use
5667

@@ -75,7 +86,7 @@ Jumping is the most important feature of all. It allows you to jump to any previ
7586
### And Much More
7687

7788
- multiple tree graph branches depicting state changes
78-
- tree graph hover functionality to view state changes
89+
- tree graph hover functionality to view state changes
7990
- ability to pan and zoom tree graph
8091
- multiple tabs support
8192
- a slider to move through snapshots quickly

src/extension/background.js

Lines changed: 30 additions & 24 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-
1211
function createTabObj(title) {
1312
// update tabsObj
1413
return {
@@ -60,7 +59,6 @@ function changeCurrLocation(tabObj, rootNode, index) {
6059
return;
6160
// if not, recurse on each one of the children
6261
}
63-
// added if (rootNode.children) { <=======
6462
if (rootNode.children) {
6563
rootNode.children.forEach(child => {
6664
changeCurrLocation(tabObj, child, index);
@@ -146,9 +144,9 @@ chrome.runtime.onMessage.addListener((request, sender) => {
146144

147145
// Filter out tabs that don't have reactime
148146
if (
149-
action === 'tabReload'
150-
|| action === 'recordSnap'
151-
|| action === 'jumpToSnap'
147+
action === 'tabReload' ||
148+
action === 'recordSnap' ||
149+
action === 'jumpToSnap'
152150
) {
153151
isReactTimeTravel = true;
154152
} else return;
@@ -181,10 +179,12 @@ chrome.runtime.onMessage.addListener((request, sender) => {
181179
tabsObj[tabId].index = 1;
182180

183181
// send a message to devtools
184-
portsArr.forEach(bg => bg.postMessage({
185-
action: 'initialConnectSnapshots',
186-
payload: tabsObj,
187-
}));
182+
portsArr.forEach(bg =>
183+
bg.postMessage({
184+
action: 'initialConnectSnapshots',
185+
payload: tabsObj,
186+
})
187+
);
188188
}
189189
reloaded[tabId] = true;
190190
break;
@@ -199,13 +199,15 @@ chrome.runtime.onMessage.addListener((request, sender) => {
199199
tabsObj[tabId].snapshots.push(request.payload);
200200
sendToHierarchy(
201201
tabsObj[tabId],
202-
new Node(request.payload, tabsObj[tabId]),
202+
new Node(request.payload, tabsObj[tabId])
203203
);
204204
if (portsArr.length > 0) {
205-
portsArr.forEach(bg => bg.postMessage({
206-
action: 'initialConnectSnapshots',
207-
payload: tabsObj,
208-
}));
205+
portsArr.forEach(bg =>
206+
bg.postMessage({
207+
action: 'initialConnectSnapshots',
208+
payload: tabsObj,
209+
})
210+
);
209211
}
210212
break;
211213
}
@@ -218,16 +220,18 @@ chrome.runtime.onMessage.addListener((request, sender) => {
218220
//! INVOKING buildHierarchy FIGURE OUT WHAT TO PASS IN!!!!
219221
sendToHierarchy(
220222
tabsObj[tabId],
221-
new Node(request.payload, tabsObj[tabId]),
223+
new Node(request.payload, tabsObj[tabId])
222224
);
223225
}
224226
// send message to devtools
225227
if (portsArr.length > 0) {
226-
portsArr.forEach(bg => bg.postMessage({
227-
action: 'sendSnapshots',
228-
payload: tabsObj,
229-
sourceTab,
230-
}));
228+
portsArr.forEach(bg =>
229+
bg.postMessage({
230+
action: 'sendSnapshots',
231+
payload: tabsObj,
232+
sourceTab,
233+
})
234+
);
231235
}
232236
break;
233237
}
@@ -240,10 +244,12 @@ chrome.runtime.onMessage.addListener((request, sender) => {
240244
chrome.tabs.onRemoved.addListener(tabId => {
241245
// tell devtools which tab to delete
242246
if (portsArr.length > 0) {
243-
portsArr.forEach(bg => bg.postMessage({
244-
action: 'deleteTab',
245-
payload: tabId,
246-
}));
247+
portsArr.forEach(bg =>
248+
bg.postMessage({
249+
action: 'deleteTab',
250+
payload: tabId,
251+
})
252+
);
247253
}
248254

249255
// delete the tab from the tabsObj

0 commit comments

Comments
 (0)