Replies: 2 comments
-
did you find any way to workaround this? since its needed to use a ref for all method calls, this seems like a blocker to use and that this component is basically unmaintained into the age of functional components rather than class components... |
Beta Was this translation helpful? Give feedback.
-
I encountered similar issue with dynamic import in nextjs and getting the same error as above.
/**
* Usage is the same as `dynamic()` from NextJS with 1 exception: `ssr` IS ALWAYS FALSE, hence the name of this function.
* @param {() => any} importCallback Ex: () => import('./LazyComponent.jsx')
* @param {{ loading?: () => import('react').ReactNode }} options This can be similar to options of `dynamic()` from NextJS
*/
export const clientOnly = (importCallback, { loading } = {}) => {
const LazyComponent = lazy(importCallback);
return forwardRef(function ClientOnlyComponent(props, forwardedRef) {
const [isClient, setIsClient] = useState(false);
useEffect(() => {
setIsClient(true);
}, []);
return (
isClient && (
<Suspense fallback={loading?.()}>
<LazyComponent
{...props}
ref={forwardedRef}
/>
</Suspense>
)
);
});
};
// ComponentB.jsx
const LazyComponentA = clientOnly(()=> import('./componentA'));
// later, use component A as normal in NextJS:
export const ComponentB = () => {
//...
return <LazyComponentA />;
};
This workaround works for me |
Beta Was this translation helpful? Give feedback.
-
Be sure to search for your issue before opening a new one.
Current Behavior
In the implementation below I receive the following error:
Expected Behavior
Based on the examples i should be able to set the ref this way
Steps to Reproduce
Version
using "react-player": "^2.15.1",
Beta Was this translation helpful? Give feedback.
All reactions