Skip to content

Commit

Permalink
fix: throw descriptive error when callbacks used with react
Browse files Browse the repository at this point in the history
  • Loading branch information
owenpearson committed Sep 25, 2023
1 parent d735e23 commit 9181064
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/platform/react-hooks/src/AblyProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export const AblyProvider = ({ client, children, id = 'default' }: AblyProviderP
throw new Error('AblyProvider: the `client` prop is required');
}

if (!(client instanceof Ably.Realtime) && !client?.options?.promises) {
throw new Error('AblyProvider: the `client` prop must take an instance of Ably.Realtime.Promise');
}

const realtime = useMemo(() => client, [client]);

let context = getContext(id);
Expand Down
1 change: 1 addition & 0 deletions src/platform/react-hooks/src/fakes/ably.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export class FakeAblySdk {
public clientId: string;
public channels: ClientChannelsCollection;
public connection: Connection;
public options = { promises: true };

constructor() {
this.clientId = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
Expand Down

0 comments on commit 9181064

Please sign in to comment.