Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions fixtures/concurrent/time-slicing/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,25 @@ class App extends PureComponent {
}

componentDidMount() {
window.addEventListener('keydown', e => {
this.handleKeydown = e => {
if (e.key.toLowerCase() === '?') {
e.preventDefault();
this.setState(state => ({
showClock: !state.showClock,
}));
}
});
};
window.addEventListener('keydown', this.handleKeydown);
}

componentWillUnmount() {
window.removeEventListener('keydown', this.handleKeydown);
}

handleChartClick = e => {
if (this.state.showDemo) {
if (e.shiftKey) {
this.setState({showDemo: false});
this.setState({ showDemo: false });
}
return;
}
Expand All @@ -63,28 +68,27 @@ class App extends PureComponent {
return;
}
this._ignoreClick = true;

startTransition(() => {
this.setState({showDemo: true}, () => {
this.setState({ showDemo: true }, () => {
this._ignoreClick = false;
});
});
};

debouncedHandleChange = _.debounce(value => {
if (this.state.strategy === 'debounced') {
this.setState({value: value});
this.setState({ value: value });
}
}, 1000);

renderOption(strategy, label) {
const {strategy: currentStrategy} = this.state;
const { strategy: currentStrategy } = this.state;
return (
<label className={strategy === currentStrategy ? 'selected' : null}>
<input
type="radio"
checked={strategy === currentStrategy}
onChange={() => this.setState({strategy})}
onChange={() => this.setState({ strategy })}
/>
{label}
</label>
Expand All @@ -93,18 +97,18 @@ class App extends PureComponent {

handleChange = e => {
const value = e.target.value;
const {strategy} = this.state;
const { strategy } = this.state;
switch (strategy) {
case 'sync':
this.setState({value});
this.setState({ value });
break;
case 'debounced':
this.debouncedHandleChange(value);
break;
case 'async':
// TODO: useTransition hook instead.
startTransition(() => {
this.setState({value});
this.setState({ value });
});
break;
default:
Expand All @@ -113,7 +117,7 @@ class App extends PureComponent {
};

render() {
const {showClock} = this.state;
const { showClock } = this.state;
const data = this.getStreamData(this.state.value);
return (
<div className="container">
Expand All @@ -123,7 +127,7 @@ class App extends PureComponent {
{this.renderOption('async', 'Concurrent')}
</div>
<input
className={'input ' + this.state.strategy}
className={"input " + this.state.strategy}
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quote style has been changed from single quotes to double quotes, which is inconsistent with the rest of the codebase. The file and related files in this fixture consistently use single quotes for string literals. This should use single quotes for consistency with the codebase convention.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent quote style: double quotes are used here while the rest of the codebase consistently uses single quotes for string literals. For example, Charts.js line 19 and other parts of this file use single quotes.

Copilot uses AI. Check for mistakes.
placeholder="longer input → more components and DOM nodes"
defaultValue={this.state.input}
onChange={this.handleChange}
Expand All @@ -132,7 +136,7 @@ class App extends PureComponent {
{this.state.showDemo && (
<Charts data={data} onClick={this.handleChartClick} />
)}
<div style={{display: showClock ? 'block' : 'none'}}>
<div style={{ display: showClock ? "block" : "none" }}>
<Clock />
</div>
</div>
Expand All @@ -143,4 +147,4 @@ class App extends PureComponent {

const container = document.getElementById('root');
const root = createRoot(container);
root.render(<App />);
root.render(<App />);
Loading