Skip to content

Commit fb8ad06

Browse files
prepare 2.15.1 release (#14)
1 parent 2f1011a commit fb8ad06

File tree

12 files changed

+3765
-4434
lines changed

12 files changed

+3765
-4434
lines changed

examples/async-provider/package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@
2626
"dependencies": {
2727
"@babel/polyfill": "^7.2.5",
2828
"express": "^4.16.4",
29-
"launchdarkly-react-client-sdk": "^2.13.0",
30-
"ldclient-node": "^5.7.2",
29+
"launchdarkly-react-client-sdk": "^2.15.0",
3130
"lodash": "^4.17.11",
3231
"prop-types": "^15.7.2",
33-
"react": "^16.8.4",
34-
"react-dom": "^16.8.4",
35-
"react-router-dom": "^4.3.1",
32+
"react": "^16.11.0",
33+
"react-dom": "^16.11.0",
34+
"react-router-dom": "^5.1.2",
3635
"styled-components": "^4.1.3"
3736
},
3837
"devDependencies": {
@@ -53,7 +52,7 @@
5352
"eslint-plugin-import": "^2.14.0",
5453
"eslint-plugin-jsx-a11y": "^6.1.2",
5554
"eslint-plugin-react": "^7.11.1",
56-
"universal-hot-reload": "^3.3.3",
55+
"universal-hot-reload": "^3.3.4",
5756
"webpack": "^4.39.3",
5857
"webpack-cli": "^3.3.7",
5958
"webpack-node-externals": "^1.7.2",

examples/async-provider/src/client/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import React from 'react';
2-
import { hydrate } from 'react-dom';
2+
import { render } from 'react-dom';
33
import { BrowserRouter } from 'react-router-dom';
44
import { asyncWithLDProvider } from 'launchdarkly-react-client-sdk';
55
import App from '../universal/app';
66

77
(async () => {
88
const LDProvider = await asyncWithLDProvider({ clientSideID: '59b2b2596d1a250b1c78baa4' });
99

10-
hydrate(
10+
render(
1111
<BrowserRouter>
1212
<LDProvider>
1313
<App />

examples/async-provider/yarn.lock

Lines changed: 1680 additions & 2250 deletions
Large diffs are not rendered by default.

examples/hoc/package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@
2626
"dependencies": {
2727
"@babel/polyfill": "^7.2.5",
2828
"express": "^4.16.4",
29-
"ldclient-node": "^5.7.2",
30-
"launchdarkly-react-client-sdk": "^2.13.0",
29+
"launchdarkly-react-client-sdk": "^2.15.0",
3130
"lodash": "^4.17.11",
3231
"prop-types": "^15.7.2",
33-
"react": "^16.8.4",
34-
"react-dom": "^16.8.4",
35-
"react-router-dom": "^4.3.1",
32+
"react": "^16.11.0",
33+
"react-dom": "^16.11.0",
34+
"react-router-dom": "^5.1.2",
3635
"styled-components": "^4.1.3"
3736
},
3837
"devDependencies": {
@@ -52,7 +51,7 @@
5251
"eslint-plugin-import": "^2.14.0",
5352
"eslint-plugin-jsx-a11y": "^6.1.2",
5453
"eslint-plugin-react": "^7.11.1",
55-
"universal-hot-reload": "^2.0.1",
54+
"universal-hot-reload": "^3.3.4",
5655
"webpack": "^4.27.1",
5756
"webpack-cli": "^3.1.2",
5857
"webpack-node-externals": "^1.7.2",

examples/hoc/src/client/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
2-
import { hydrate } from 'react-dom';
2+
import { render } from 'react-dom';
33
import { BrowserRouter } from 'react-router-dom';
44
import App from '../universal/app';
55

6-
hydrate(
6+
render(
77
<BrowserRouter>
88
<App />
99
</BrowserRouter>,

examples/hoc/src/server/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
const UniversalHotReload = require('universal-hot-reload').default;
2-
UniversalHotReload(require('../../webpack.config.server.js'), require('../../webpack.config.client.js'));
2+
3+
// supply your own webpack configs
4+
const serverConfig = require('../../webpack.config.server.js');
5+
const clientConfig = require('../../webpack.config.client.js');
6+
7+
// the configs are optional, you can supply either one or both.
8+
// if you omit say the server config, then your server won't hot reload.
9+
UniversalHotReload({ serverConfig, clientConfig });

examples/hoc/yarn.lock

Lines changed: 1990 additions & 2006 deletions
Large diffs are not rendered by default.

src/asyncWithLDProvider.test.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,20 @@ describe('asyncWithLDProvider', () => {
9898
expect(receivedNode).toHaveTextContent('{"another-test-flag":false,"test-flag":false}');
9999
});
100100

101+
test('consecutive flag changes gets stored in context correctly', async () => {
102+
mockLDClient.on.mockImplementationOnce((e: string, cb: (c: LDFlagChangeset) => void) => {
103+
cb({ 'another-test-flag': { current: false, previous: true } });
104+
105+
// simulate second update
106+
cb({ 'test-flag': { current: false, previous: true } });
107+
});
108+
109+
const receivedNode = await renderWithConfig({ clientSideID });
110+
111+
expect(mockLDClient.on).toHaveBeenNthCalledWith(1, 'change', expect.any(Function));
112+
expect(receivedNode).toHaveTextContent('{"testFlag":false,"anotherTestFlag":false}');
113+
});
114+
101115
test('ldClient bootstraps correctly', async () => {
102116
// don't subscribe to changes to test bootstrap
103117
mockLDClient.on.mockImplementation((e: string, cb: (c: LDFlagChangeset) => void) => {
@@ -113,6 +127,18 @@ describe('asyncWithLDProvider', () => {
113127
expect(receivedNode).toHaveTextContent('{"anotherTestFlag":false,"testFlag":true}');
114128
});
115129

130+
test('ldClient bootstraps with empty flags', async () => {
131+
// don't subscribe to changes to test bootstrap
132+
mockLDClient.on.mockImplementation((e: string, cb: (c: LDFlagChangeset) => void) => {
133+
return;
134+
});
135+
const options: LDOptions = {
136+
bootstrap: {},
137+
};
138+
const receivedNode = await renderWithConfig({ clientSideID, user, options });
139+
expect(receivedNode).toHaveTextContent('{}');
140+
});
141+
116142
test('ldClient bootstraps correctly with kebab-case', async () => {
117143
// don't subscribe to changes to test bootstrap
118144
mockLDClient.on.mockImplementation((e: string, cb: (c: LDFlagChangeset) => void) => {
@@ -146,7 +172,7 @@ describe('asyncWithLDProvider', () => {
146172
flags: { devTestFlag: true, launchDoggly: true },
147173
ldClient: mockLDClient,
148174
}));
149-
const options: LDOptions = { bootstrap: {} };
175+
const options: LDOptions = {};
150176
const flags = { 'dev-test-flag': false, 'launch-doggly': false };
151177
const receivedNode = await renderWithConfig({ clientSideID, user, options, flags });
152178

src/asyncWithLDProvider.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default async function asyncWithLDProvider(config: ProviderConfig) {
4141
const { bootstrap } = options;
4242
if (bootstrap && bootstrap !== 'localStorage') {
4343
const bootstrappedFlags = reactOptions.useCamelCaseFlagKeys ? camelCaseKeys(bootstrap) : bootstrap;
44-
setLDData({ flags: bootstrappedFlags, ldClient });
44+
setLDData(prev => ({ ...prev, flags: bootstrappedFlags }));
4545
}
4646
}
4747

@@ -52,7 +52,8 @@ export default async function asyncWithLDProvider(config: ProviderConfig) {
5252
const flagKey = reactOptions.useCamelCaseFlagKeys ? camelCase(key) : key;
5353
flattened[flagKey] = changes[key].current;
5454
}
55-
setLDData({ flags: { ...ldData.flags, ...flattened }, ldClient });
55+
56+
setLDData(prev => ({ ...prev, flags: { ...prev.flags, ...flattened } }));
5657
});
5758
}, []);
5859

src/withLDProvider.test.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ describe('withLDProvider', () => {
4848
expect(mockInitLDClient).toHaveBeenCalledWith(clientSideID, user, defaultReactOptions, options, undefined);
4949
});
5050

51+
test.only('ldClient bootstraps with empty flags', () => {
52+
const user: LDUser = { key: 'yus', name: 'yus ng' };
53+
const options: LDOptions = {
54+
bootstrap: {},
55+
};
56+
const LaunchDarklyApp = withLDProvider({ clientSideID, user, options })(App);
57+
const component = shallow(<LaunchDarklyApp />, { disableLifecycleMethods: true });
58+
const initialState = component.state() as HocState;
59+
60+
expect(initialState.flags).toEqual({});
61+
});
62+
5163
test('ld client is bootstrapped correctly and transforms keys to camel case', () => {
5264
const user: LDUser = { key: 'yus', name: 'yus ng' };
5365
const options: LDOptions = {

0 commit comments

Comments
 (0)