Skip to content

Commit 7f88d45

Browse files
authored
Merge pull request #281 from open-source-labs/dev50
Reactime Update V14.0
2 parents 89c4310 + 71e6b89 commit 7f88d45

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2138
-1330
lines changed

README.md

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<br>
1010
</h1>
1111

12-
<h4 align="center"> Reactime is a performance and debugging tool for React developers <b>(Beta version for Gatsby and Next.js)</b>. It records a snapshot whenever a target application's state is changed and allows the user to jump to any previously recorded state. It also detects the amount of renders of each component and average time of rendering.</h4>
12+
<h4 align="center"> Reactime is an open source Chrome developer tool for time travel debugging and performance monitoring in React applications. Reactime enables developers to record snapshots of application state, jump between and inspect state snapshots, and monitor performance metrics such as component render time and render frequency. </h4>
1313

1414
<br>
1515
<p align="center">
@@ -43,18 +43,18 @@
4343
<a href="#how-to-use">How To Use</a> • <a href="#features">Features</a> • <a href="https://reactime.io">Website</a> • <a href="#read-more">Read More</a>
4444
</p>
4545

46-
Currently, Reactime supports React apps using stateful components and Hooks, with beta support for Recoil and Context API and frameworks like Gatsby and Next.js.
46+
Currently, Reactime supports React apps (now including React Router apps) using stateful components and Hooks, with beta support for Recoil and Context API and frameworks like Gatsby and Next.js.
4747

48-
<b>Reactime 13.0</b> has added the exciting features below:
48+
<b>Reactime 14.0</b> has added the exciting features below:
4949

50-
I. Action Comparison Tool
51-
Users now have the ability to name, save, and analyze specific action snapshots within a saved series. This feature allows engineers to compare component render times throughout the development process of their application, providing them with metrics to show any improvements or changes.
50+
I. React Router Compatibility <br>
51+
Reactime is now compatible with React Router applications! Prior to Reactime 14.0, recording state snapshots as the user navigated across various routes was possible, but time travel debugging was only possible for the current route (i.e. jumping back to a prior state at a different route was not possible). In order to streamline debugging of applications with multiple routes, Reactime 14.0 added functionality that allows the user to time-travel back to different routes, including live updating in the browser to reflect the state of their application at that previously visited route.
5252

53-
II. Reactime Visual Tutorial Walkthrough
54-
While Reactime offers a user friendly and intuitive interface, users can now access a guided tutorial, walking the user through each feature while explaining practical use cases and added benefits that Reactime can provide. The walkthrough utilizes the Intro.js library, providing a visual experience that highlights and cycles through each COMPONENT displayed on the app.
53+
II. Classifying State Snapshots by Route <br>
54+
The list of state snapshots in the Reactime dashboard is now classified by route to give the developer visual cues of the snapshot-route relationship and make time travel debugging of various routes easier.
5555

56-
III. State Monitoring Toggle Feature
57-
Added toggle feature allows users to temporarily pause Reactime's state monitoring of the linked application. This allows users to make state changes within their application without populating the actions container within Reactime. Especially useful when trying to limit and compare the number of actions within one series that a user is planning to save. Relinking Reactime to the application is as simple as toggling the record button back to it's original state!
56+
III. Filtering Performance Metrics by Route <br>
57+
The Reactime dashboard includes a stacked bar graph showing render times for each component, with a separate bar stack for each snapshot. With Reactime 14.0, this composite bar graph can now be filtered by route to allow the developer to review detailed performance data by route.
5858

5959
After installing Reactime, you can test its functionalities with your React application in development mode.
6060

@@ -92,38 +92,52 @@ Reactime is an open source project, and we’d really appreciate your help with
9292

9393
## <b>Features</b>
9494

95-
### 🔹 Re-render Optimization
96-
97-
One of the most common issues that affects performance in React is unnecessary render cycles. This problem can be fixed by checking your renders in the Performance tab in Chrome DevTools under the Reactime panel.
98-
99-
### 🔹 Gatsby
95+
### 🔹 Viewing
10096

101-
Reactime offers fully support for Gatsby applications. You would be able to identify unnecessary renders, duration of each rendering, travel-debugging features and visual representation of the tree components.
97+
You can view your application's file structure and click on a snapshot to view your app's state. State can be visualized in a Component Graph, JSON Tree, or Performance Graph. Snapshots can be diffed with the previous snapshot, which can be viewed in Diff mode.
98+
<br>
99+
<br>
100+
<p align="center">
101+
<img src="./assets/map-viewing.gif" />
102+
</p>
103+
<br>
102104

103-
### 🔹 Next.js
105+
### 🔹 Snapshot Series and Action Comparison
104106

105-
Reactime offers debugging and performance tools for Next.js apps: time-traveling debugging, preventing unnecessary components re-renders and making your application faster.
107+
You can save a series of state snapshots and use it to analyze changes in component render performance between current and previous series of snapshots. You can also name specific snapshots and compare all snapshots with the same name.
108+
<br>
109+
<br>
110+
<p align="center">
111+
<img src="./assets/action-comparison.gif" />
112+
</p>
113+
<br>
106114

107115
### 🔹 Recording
108116

109117
Whenever state is changed (whenever setState, 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.
110-
111-
### 🔹 Snapshot Series and Action Comparison
112-
113-
You can save a series of state snapshots and use it to analyze changes in component render performance between current and previous series of snapshots. You can also name specific snapshots and compare all snapshots with the same name.
118+
<br>
119+
<br>
114120
<p align="center">
115-
<img src="http://g.recordit.co/KNxvT94qxd.gif" />
121+
<img src="./assets/history-tree.gif" />
116122
</p>
117123
<br>
118124

119-
### 🔹 Viewing
125+
### 🔹 Re-render Optimization
120126

121-
You can click on a snapshot to view your app's state. State can be visualized in a Component Graph, JSON Tree, or Performance Graph. Snapshots can be diffed with the previous snapshot, which can be viewed in Diff mode.
127+
One of the most common issues that affects performance in React is unnecessary render cycles. This problem can be fixed by checking your renders in the Performance tab in Chrome DevTools under the Reactime panel.
122128

123129
### 🔹 Jumping
124130

125131
Using the actions sidebar, a user can jump to any previous recorded snapshots. Hitting the jump button on any snapshot will allow a user to view state data at any point in the history of the target application.
126132

133+
### 🔹 Gatsby
134+
135+
Reactime offers full support for Gatsby applications. You would be able to identify unnecessary renders, duration of each rendering, travel-debugging features and visual representation of the tree components.
136+
137+
### 🔹 Next.js
138+
139+
Reactime offers debugging and performance tools for Next.js apps: time-traveling debugging, preventing unnecessary components re-renders and making your application faster.
140+
127141
### 🔹 TypeScript Support
128142

129143
Reactime offers beta support for TypeScript applications using stateful class components and functional components. Further testing and development is required for custom hooks, Context API, and Concurrent Mode.
@@ -133,11 +147,6 @@ Reactime offers beta support for TypeScript applications using stateful class co
133147
After cloning this repository, developers can simply run `npm run docs` at the root level and serve the dynamically generated `/docs/index.html` file on a browser. Doing so will provide a readable, extensible, and interactive GUI view of the structure and interfaces of the codebase.
134148
<br>
135149

136-
<p align="center">
137-
<img src="./assets/nextjs.gif" />
138-
</p>
139-
<br>
140-
141150
### <b>Additional Features</b>
142151

143152
- Identifying unnecessary re-renders
@@ -222,6 +231,11 @@ After cloning this repository, developers can simply run `npm run docs` at the r
222231
- **Kristina Wallen** - [@kristinawallen](https://github.com/kristinawallen)
223232
- **Quan Le** - [@blachfog](https://github.com/Blachfog)
224233
- **Robert Maeda** - [@robmaeda](https://github.com/robmaeda)
234+
- **David Kim** - [@codejunkie7](https://github.com/codejunkie7)
235+
- **Robby Tipton** - [@RobbyTipton](https://github.com/RobbyTipton)
236+
- **Kevin HoEun. Lee** - [@khobread](https://github.com/khobread)
237+
- **Christopher LeBrett** - [@fscgolden](https://github.com/fscgolden)
238+
- **Joseph Park** - [@joeepark](https://github.com/joeepark)
225239

226240
## <b>License </b>
227241

assets/action-comparison.gif

5.94 MB
Loading

assets/history-tree.gif

2.48 MB
Loading

assets/map-viewing.gif

4.15 MB
Loading

assets/new-reactime.gif

4.34 MB
Loading

demo-app/.babelrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
{
3+
"presets": [
4+
"@babel/preset-env",
5+
"@babel/preset-react"
6+
]
7+
}

demo-app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

demo-app/package.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "typescript-module",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"start": "webpack-dev-server",
8+
"test": "echo \"Error: no test specified\" && exit 1"
9+
},
10+
"devDependencies": {
11+
"@babel/core": "^7.16.7",
12+
"@babel/preset-env": "^7.16.7",
13+
"@babel/preset-react": "^7.16.7",
14+
"@types/express": "^4.17.13",
15+
"@types/node": "^17.0.8",
16+
"@types/react": "^17.0.38",
17+
"@types/react-dom": "^17.0.11",
18+
"babel-loader": "^8.2.3",
19+
"copy-webpack-plugin": "^10.2.0",
20+
"css-loader": "^6.5.1",
21+
"html-webpack-plugin": "^5.5.0",
22+
"nodemon": "^2.0.15",
23+
"ts-loader": "^9.2.6",
24+
"typescript": "^4.5.4",
25+
"webpack": "^5.65.0",
26+
"webpack-cli": "^4.9.1",
27+
"webpack-dev-server": "^4.7.2"
28+
},
29+
"dependencies": {
30+
"express": "^4.17.2",
31+
"react": "^18.1.0",
32+
"react-dom": "^18.1.0",
33+
"react-router-dom": "^6.3.0",
34+
"ts-node": "^10.4.0"
35+
}
36+
}
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
import React, { Component } from 'react';
2+
import Row from './Row';
3+
import { BoardText, BoardContent, Scoreboard, Player } from './../../types';
4+
5+
type BoardState = {
6+
board: BoardContent;
7+
currentPlayer: Player;
8+
gameOver: boolean;
9+
message: string;
10+
scoreboard: Scoreboard;
11+
};
12+
13+
class Board extends Component<{}, BoardState> {
14+
constructor(props: any) {
15+
super(props);
16+
this.state = {
17+
board: this.newBoard(),
18+
currentPlayer: 'X',
19+
gameOver: false,
20+
message: '',
21+
scoreboard: { X: 0, O: 0 },
22+
};
23+
24+
this.resetBoard = this.resetBoard.bind(this);
25+
this.handleBoxClick = this.handleBoxClick.bind(this);
26+
}
27+
28+
componentDidUpdate() {
29+
this.checkForWinner();
30+
}
31+
32+
/**
33+
* @method newBoard
34+
* @description - returns a blank BoardContent array,
35+
* for the start of a new game
36+
*/
37+
newBoard(): BoardContent {
38+
return [
39+
['-', '-', '-'],
40+
['-', '-', '-'],
41+
['-', '-', '-'],
42+
];
43+
}
44+
45+
/**
46+
* @method resetBoard
47+
* @description - sets to board object to be all '-',
48+
* and sets gameOver and message to default state
49+
*/
50+
resetBoard(): void {
51+
this.setState({
52+
gameOver: false,
53+
board: this.newBoard(),
54+
message: '',
55+
});
56+
}
57+
58+
/**
59+
* @method checkForWinner
60+
* @description - checks to see if either player has filled a row
61+
* if so, ends the game and updates the message to declare winner
62+
*/
63+
checkForWinner(): void {
64+
const { board, gameOver, currentPlayer } = this.state;
65+
66+
const spacesLeft = (): boolean => {
67+
for (let i of board) {
68+
if (i.includes('-')) return true;
69+
}
70+
return false;
71+
};
72+
73+
if (!gameOver) {
74+
// win conditions: matching rows, columns, or diagonals, that are not empty('-')
75+
if (
76+
(board[0][0] === board[0][1] &&
77+
board[0][1] === board[0][2] &&
78+
board[0][2] !== '-') ||
79+
(board[1][0] === board[1][1] &&
80+
board[1][1] === board[1][2] &&
81+
board[1][2] !== '-') ||
82+
(board[2][0] === board[2][1] &&
83+
board[2][1] === board[2][2] &&
84+
board[2][2] !== '-') ||
85+
(board[0][0] === board[1][0] &&
86+
board[1][0] === board[2][0] &&
87+
board[2][0] !== '-') ||
88+
(board[0][1] === board[1][1] &&
89+
board[1][1] === board[2][1] &&
90+
board[2][1] !== '-') ||
91+
(board[0][2] === board[1][2] &&
92+
board[1][2] === board[2][2] &&
93+
board[2][2] !== '-') ||
94+
(board[0][0] === board[1][1] &&
95+
board[1][1] === board[2][2] &&
96+
board[2][2] !== '-') ||
97+
(board[2][0] === board[1][1] &&
98+
board[1][1] === board[0][2] &&
99+
board[0][2] !== '-')
100+
) {
101+
// winner is the person who's turn was previous
102+
const winner: Player = currentPlayer === 'X' ? 'O' : 'X';
103+
104+
this.setState({
105+
gameOver: true,
106+
message: `Player ${winner} wins!`,
107+
});
108+
109+
// draw condition: no '-' remaining in board without above win condition triggering
110+
} else if (!spacesLeft()) {
111+
this.setState({
112+
gameOver: true,
113+
message: 'Draw!',
114+
});
115+
}
116+
}
117+
}
118+
119+
handleBoxClick(row: number, column: number): void {
120+
const boardCopy: BoardContent = [
121+
[...this.state.board[0]],
122+
[...this.state.board[1]],
123+
[...this.state.board[2]],
124+
];
125+
boardCopy[row][column] = this.state.currentPlayer;
126+
const newPlayer: Player = this.state.currentPlayer === 'X' ? 'O' : 'X';
127+
this.setState({ board: boardCopy, currentPlayer: newPlayer });
128+
}
129+
130+
render() {
131+
const rows: Array<JSX.Element> = [];
132+
for (let i = 0; i < 3; i++) {
133+
rows.push(
134+
<Row
135+
key={i}
136+
row={i}
137+
handleBoxClick={this.handleBoxClick}
138+
values={this.state.board[i]}
139+
/>
140+
);
141+
}
142+
const { X, O }: Scoreboard = this.state.scoreboard;
143+
144+
return (
145+
<div className="board">
146+
<h1>Tic Tac Toe</h1>
147+
{this.state.gameOver && <h4>{this.state.message}</h4>}
148+
{rows}
149+
<button id="reset" onClick={this.resetBoard}>
150+
Reset
151+
</button>
152+
</div>
153+
);
154+
}
155+
}
156+
157+
export default Board;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import { BoardText } from '../../types';
3+
4+
type BoxProps = {
5+
value: BoardText;
6+
row: number;
7+
column: number;
8+
handleBoxClick: (row: number, column: number) => void;
9+
};
10+
11+
const Box = (props: BoxProps) => {
12+
return (
13+
<button
14+
className="box"
15+
onClick={(e) => props.handleBoxClick(props.row, props.column)}
16+
>
17+
{props.value}
18+
</button>
19+
);
20+
};
21+
22+
export default Box;

0 commit comments

Comments
 (0)