Skip to content

Commit 131762d

Browse files
authored
prepare 3.0.10 release (#233)
## [3.0.10] - 2023-12-07 ### Fixed: - Added deferred initialization example. - Fixes #228. Bumped js sdk dependency.
2 parents 3f39b0b + 67ab44e commit 131762d

File tree

19 files changed

+524
-41
lines changed

19 files changed

+524
-41
lines changed

examples/async-provider/yarn.lock

Lines changed: 159 additions & 25 deletions
Large diffs are not rendered by default.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# LaunchDarkly SDK for React - Example deferred initialization app
2+
3+
This is a CRA typescript app demonstrating `launchdarkly-react-client-sdk` and how to defer the LDClient initialization.
4+
5+
The LDClient will not be initialized on initial render until a context is set. This is done through clicking the "Login" button in this example app.
6+
7+
## Running the deferred initialization example
8+
9+
Follow these steps to run the app:
10+
11+
- Create a `.env.local` file and set your clientSideID there like so:
12+
13+
```shell
14+
REACT_APP_LD_CLIENT_SIDE_ID=xxx
15+
```
16+
17+
- Create a flag called `dev-test-flag` in your project. Make sure you
18+
make the flag available to the client-side SDK.
19+
20+
- You should now be able to start the app by doing:
21+
22+
```sh
23+
yarn && yarn start
24+
```
25+
26+
- The LDClient will not be initialized on initial render until a context is set. This is done when the login button is clicked.
27+
- Toggle the killswitch for `dev-test-flag` in the dashboard and the
28+
app should respond without a browser refresh.
29+
30+
# Getting Started with Create React App
31+
32+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
33+
34+
## Available Scripts
35+
36+
In the project directory, you can run:
37+
38+
### `npm start`
39+
40+
Runs the app in the development mode.\
41+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
42+
43+
The page will reload if you make edits.\
44+
You will also see any lint errors in the console.
45+
46+
### `npm test`
47+
48+
Launches the test runner in the interactive watch mode.\
49+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
50+
51+
### `npm run build`
52+
53+
Builds the app for production to the `build` folder.\
54+
It correctly bundles React in production mode and optimizes the build for the best performance.
55+
56+
The build is minified and the filenames include the hashes.\
57+
Your app is ready to be deployed!
58+
59+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
60+
61+
### `npm run eject`
62+
63+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
64+
65+
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
66+
67+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
68+
69+
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
70+
71+
## Learn More
72+
73+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
74+
75+
To learn React, check out the [React documentation](https://reactjs.org/).
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"name": "deferred-initialization",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@testing-library/jest-dom": "^5.16.5",
7+
"@testing-library/react": "^13.4.0",
8+
"@testing-library/user-event": "^13.5.0",
9+
"@types/jest": "^27.5.2",
10+
"@types/node": "^16.18.18",
11+
"@types/react": "^18.0.28",
12+
"@types/react-dom": "^18.0.11",
13+
"launchdarkly-react-client-sdk": "^3.0.9",
14+
"react": "^18.2.0",
15+
"react-dom": "^18.2.0",
16+
"react-scripts": "5.0.1",
17+
"typescript": "^4.9.5",
18+
"web-vitals": "^2.1.4"
19+
},
20+
"scripts": {
21+
"analyze": "source-map-explorer 'build/static/js/*.js'",
22+
"start": "react-scripts start",
23+
"build": "react-scripts build",
24+
"test": "react-scripts test",
25+
"eject": "react-scripts eject",
26+
"postinstall": "cd ../../ && yarn link-dev",
27+
"tsc": "tsc"
28+
},
29+
"eslintConfig": {
30+
"extends": [
31+
"react-app",
32+
"react-app/jest"
33+
]
34+
},
35+
"browserslist": {
36+
"production": [
37+
">0.2%",
38+
"not dead",
39+
"not op_mini all"
40+
],
41+
"development": [
42+
"last 1 chrome version",
43+
"last 1 firefox version",
44+
"last 1 safari version"
45+
]
46+
},
47+
"devDependencies": {
48+
"source-map-explorer": "2.5.3"
49+
}
50+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html lang='en'>
3+
<head>
4+
<meta charset='UTF-8'>
5+
<title>Title</title>
6+
</head>
7+
<body>
8+
<div id="root"></div>
9+
</body>
10+
</html>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.App {
2+
text-align: center;
3+
}
4+
5+
.App-logo {
6+
height: 40vmin;
7+
pointer-events: none;
8+
}
9+
10+
@media (prefers-reduced-motion: no-preference) {
11+
.App-logo {
12+
animation: App-logo-spin infinite 20s linear;
13+
}
14+
}
15+
16+
.App-header {
17+
background-color: #282c34;
18+
min-height: 100vh;
19+
display: flex;
20+
flex-direction: column;
21+
align-items: center;
22+
justify-content: center;
23+
font-size: calc(10px + 2vmin);
24+
color: white;
25+
}
26+
27+
.App-link {
28+
color: #61dafb;
29+
}
30+
31+
@keyframes App-logo-spin {
32+
from {
33+
transform: rotate(0deg);
34+
}
35+
to {
36+
transform: rotate(360deg);
37+
}
38+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
import { render, screen } from '@testing-library/react';
3+
import App from './App';
4+
5+
test('renders learn react link', () => {
6+
render(<App />);
7+
const linkElement = screen.getByText(/learn react/i);
8+
expect(linkElement).toBeInTheDocument();
9+
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React, { useState } from 'react';
2+
import logo from './logo.svg';
3+
import Welcome from './welcome';
4+
import { LDProvider, LDContext } from 'launchdarkly-react-client-sdk';
5+
6+
// tslint:disable-next-line:no-import-side-effect
7+
import './App.css';
8+
9+
const clientSideID = process.env.REACT_APP_LD_CLIENT_SIDE_ID ?? '';
10+
11+
function App() {
12+
const [context, setContext] = useState<LDContext>();
13+
14+
function onClickLogin() {
15+
setContext({ kind: 'user', key: 'yus' });
16+
}
17+
18+
return (
19+
<LDProvider clientSideID={clientSideID} deferInitialization={true} context={context}>
20+
<div className="App">
21+
<header className="App-header">
22+
<img src={logo} className="App-logo" alt="logo" />
23+
<Welcome />
24+
<a className="App-link" href="https://reactjs.org" target="_blank" rel="noopener noreferrer">
25+
Learn React
26+
</a>
27+
<p>
28+
<button onClick={onClickLogin}>Login</button>
29+
</p>
30+
</header>
31+
</div>
32+
</LDProvider>
33+
);
34+
}
35+
36+
export default App;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
body {
2+
margin: 0;
3+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5+
sans-serif;
6+
-webkit-font-smoothing: antialiased;
7+
-moz-osx-font-smoothing: grayscale;
8+
}
9+
10+
code {
11+
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12+
monospace;
13+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
// tslint:disable-next-line:no-submodule-imports
3+
import ReactDOM from 'react-dom/client';
4+
import App from './App';
5+
import reportWebVitals from './reportWebVitals';
6+
7+
// tslint:disable-next-line:no-import-side-effect
8+
import './index.css';
9+
10+
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
11+
root.render(
12+
<React.StrictMode>
13+
<App />
14+
</React.StrictMode>,
15+
);
16+
17+
// If you want to start measuring performance in your app, pass a function
18+
// to log results (for example: reportWebVitals(console.log))
19+
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
20+
reportWebVitals();

0 commit comments

Comments
 (0)