import OT, {
Device, Publisher, Session, SubscriberProperties
} from '@opentok/client';
I'm encountering an issue while attempting to
import the @opentok/client library dynamically in a React application to reduce bundle size. Here's the code I'm using:
const OT = React.lazy(() => import('@opentok/client'));
I am importing this into context provider. But facing this typescript error
Type 'Promise<{ default: typeof OT; checkScreenSharingCapability(callback: (response: ScreenSharingCapabilityResponse) => void): void; checkSystemRequirements(): number; ... 25 more ...; Subscriber: typeof Subscriber; }>' is not assignable to type 'Promise<{ default: ComponentType<any>; }>'.
Type '{ default: typeof OT; checkScreenSharingCapability(callback: (response: ScreenSharingCapabilityResponse) => void): void; checkSystemRequirements(): number; ... 25 more ...; Subscriber: typeof Subscriber; }' is not assignable to type '{ default: ComponentType<any>; }'.
Types of property 'default' are incompatible.
Type 'typeof OT' is not assignable to type 'ComponentType<any>'.ts(2322)
Can we import library dynamically in react.js?