Pass props to the placeholder component when using dynamic #61725
skolodyazhnyy
started this conversation in
Ideas
Replies: 2 comments
-
This would be very handy and prevent the need to create a new dynamic component for every type of loader. return React.createElement(opts.loading, {
isLoading: state.loading,
pastDelay: state.pastDelay,
props,
timedOut: state.timedOut,
error: state.error,
retry: subscription.retry,
})` |
Beta Was this translation helpful? Give feedback.
0 replies
-
This would also be great to for example use a regular div while framer motion is loading. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
No response
Background
When using
dynamic
it's possible to specify a "loading" component, one which will be rendered in place of actual component while it's being loaded. Unfortunately there is no way to access properties of the dynamic component in the "loading" component so it can make a better placeholder for the content being loaded.For example,
Here while
Snippet
is being loaded I would like to render a simplified version using basic<pre>
component. Then whenSnippet
component is loaded, basic version will be replaced by a more complex one.Proposal
Add property
componentProps
orprops
to the loading component, so developers can access dynamic component properties.Following example above, the solution would look something like this:
I believe everything is available here
https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/loadable.shared-runtime.tsx#L143
Beta Was this translation helpful? Give feedback.
All reactions