-
-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reorganize shared utils #1539
Reorganize shared utils #1539
Conversation
if (!mod.error) { | ||
const cacheId = `// ${id}\n${mod.code}`; | ||
const fromCache = cache.get(cacheId); | ||
const loadedModules = React.useMemo(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wrapping in a useMemo
to satisfy https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-constructed-context-values.md
Hide whitespace to see the real changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also reordering a bit the utility imports from @mui/toolpad-core in anticipation of creating a utils package that we can reuse. @mui/toolpad-core is intended to share logic between the components and the runtime, we should aim at keeping it lean, utilities meant for broader use can go in new package. For this package we will encourage subpath imports to maximize treeshakeability e.g.
Sounds great to keep the bundle size low!
Signed-off-by: Jan Potoms <2109932+Janpot@users.noreply.github.com>
Create a
useNonNullableContext
function to replacecreateProvidedContext
down the line. The problem withcreateProvidedContext
is that it makes it impossible for the react eslint rules to detect stable/unstable context values. In this PR I'm replacing some instances ofcreateProvidedContext
with this new hook and fixing the associate eslint issuesI'm also reordering a bit the utility imports from
@mui/toolpad-core
in anticipation of creating a utils package that we can reuse.@mui/toolpad-core
is intended to share logic between the components and the runtime, we should aim at keeping it lean, utilities meant for broader use can go in new package. For this package we will encourage subpath imports to maximize treeshakeability e.g.I'm not making that switch in this PR, but as a first step, I'm just disallowing importing utilities from
@mui/toolpad-core
.