Skip to content

Conversation

EugeneChoi4
Copy link
Contributor

There was a bug in the Compiler Playground related to the "Show Internals" toggle due to a useEffect that was causing the tab names to flicker from a rerender. Rewritten instead with a <Suspense> boundary + use.

return tabifyCache.get(key)!;
}
const result = tabify(store.source, compilerOutput, store.showInternals);
tabifyCache.set(key, result);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you're using the store as a key this will continue growing forever (potentially on every keystroke) and include the whole store object. This should probably be some form of LRU cache that can clean up the old store keys and promises.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I missed that, thanks for the catch!

export const BASIC_OUTPUT_TAB_NAMES = ['Output', 'SourceMap'];

const tabifyCache = new LRUCache<Store, Promise<Map<string, ReactNode>>>({
max: 100,
Copy link
Contributor

Choose a reason for hiding this comment

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

Holding 100 copies of the store still seems like a lot? How many do you really need here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right–the cache should not be doing much aside from being used for the use anyways, I'll lower it.

@EugeneChoi4 EugeneChoi4 merged commit 250f1b2 into facebook:main Sep 25, 2025
21 checks passed
github-actions bot pushed a commit to code/lib-react that referenced this pull request Sep 27, 2025
There was a bug in the Compiler Playground related to the "Show
Internals" toggle due to a useEffect that was causing the tab names to
flicker from a rerender. Rewritten instead with a `<Suspense>` boundary
+ `use`.

DiffTrain build for [250f1b2](facebook@250f1b2)
github-actions bot pushed a commit to code/lib-react that referenced this pull request Sep 27, 2025
There was a bug in the Compiler Playground related to the "Show
Internals" toggle due to a useEffect that was causing the tab names to
flicker from a rerender. Rewritten instead with a `<Suspense>` boundary
+ `use`.

DiffTrain build for [250f1b2](facebook@250f1b2)
EugeneChoi4 added a commit to EugeneChoi4/react that referenced this pull request Sep 29, 2025
There was a bug in the Compiler Playground related to the "Show
Internals" toggle due to a useEffect that was causing the tab names to
flicker from a rerender. Rewritten instead with a `<Suspense>` boundary
+ `use`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants