Skip to content

Commit 382252b

Browse files
authored
prepare 3.3.1 release (#284)
## [3.3.1] - 2024-05-28 ### Fixed: - Fixed a bug introduced after the init timeout change. The ldClient object was omitted from provider state, causing the useLDClient hook to return undefined.
2 parents 21ce9fe + 3443dbf commit 382252b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/asyncWithLDProvider.test.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ const renderWithConfig = async (config: AsyncProviderConfig) => {
3939
const { getByText } = render(
4040
<LDProvider>
4141
<Consumer>
42-
{(value) => <span>Received: {`Flags: ${JSON.stringify(value.flags)}.\nError: ${value.error?.message}.`}</span>}
42+
{(value) => (
43+
<span>
44+
Received:{' '}
45+
{`Flags: ${JSON.stringify(value.flags)}.
46+
Error: ${value.error?.message}.
47+
ldClient: ${value.ldClient ? 'initialized' : 'undefined'}.`}
48+
</span>
49+
)}
4350
</Consumer>
4451
</LDProvider>,
4552
);
@@ -318,6 +325,11 @@ describe('asyncWithLDProvider', () => {
318325
expect(receivedNode).toHaveTextContent('{"testFlag":true,"anotherTestFlag":true}');
319326
});
320327

328+
test('internal ldClient state should be initialised', async () => {
329+
const receivedNode = await renderWithConfig({ clientSideID, context, options });
330+
expect(receivedNode).toHaveTextContent('ldClient: initialized');
331+
});
332+
321333
test('ldClient is initialised correctly with target flags', async () => {
322334
options = { ...wrapperOptions };
323335
const flags = { 'test-flag': false };

src/asyncWithLDProvider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export default async function asyncWithLDProvider(config: AsyncProviderConfig) {
5252
const [ldData, setLDData] = useState<ProviderState>(() => ({
5353
unproxiedFlags: initialFlags,
5454
...getFlagsProxy(ldClient, initialFlags, reactOptions, targetFlags),
55+
ldClient,
5556
error,
5657
}));
5758

0 commit comments

Comments
 (0)