Skip to content

Commit 1eeca07

Browse files
authored
refactor: make react hello example follow specs (#1233)
This PR will rewrite the `client-only` example into our official `hello-react` example. The `hello-react` example is much simpler than the previous `client-only` and does only the things described in the hello example specs. ## Caveats I still have the `client-only` example in my local instance... I think we can think about adding it in if there is a demand for more complex sample applications <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: changes are limited to example app code and CI workflows that run example e2e tests; main SDK logic is untouched, but CI could fail if the new workspace name or dependencies are misconfigured. > > **Overview** > Switches React example coverage from the old `@internal/react-sdk-example-client-only` app to a new, spec-aligned `hello-react` example, and updates both `react.yml` and `react-nightly.yaml` to run its Playwright e2e tests. > > Removes the `client-only` example from workspaces and replaces it with `packages/sdk/react/examples/hello-react`, including new top-level examples docs (`packages/sdk/react/examples/README.md`) and ignore rules. The `hello-react` app is simplified (no context switching / flag-key form) and its workspace now pins `@launchdarkly/react-sdk` to `0.1.1` instead of using the monorepo `workspace:^` dependency. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 8ead7b3. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/launchdarkly/js-core/pull/1233" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end -->
1 parent 66a2de5 commit 1eeca07

File tree

23 files changed

+105
-165
lines changed

23 files changed

+105
-165
lines changed

.github/workflows/react-nightly.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ jobs:
1616
node-version: 24
1717
- uses: ./actions/run-example
1818
with:
19-
workspace_name: '@internal/react-sdk-example-client-only'
19+
workspace_name: '@internal/react-sdk-example-hello-react'
2020
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
21-
before_test: 'yarn workspace @internal/react-sdk-example-client-only playwright install --with-deps chromium'
21+
before_test: 'yarn workspace @internal/react-sdk-example-hello-react playwright install --with-deps chromium'

.github/workflows/react.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ jobs:
9292
node-version: 24
9393
- uses: ./actions/run-example
9494
with:
95-
workspace_name: '@internal/react-sdk-example-client-only'
95+
workspace_name: '@internal/react-sdk-example-hello-react'
9696
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
97-
before_test: 'yarn workspace @internal/react-sdk-example-client-only playwright install --with-deps chromium'
97+
before_test: 'yarn workspace @internal/react-sdk-example-hello-react playwright install --with-deps chromium'
9898

9999
run-server-only-example:
100100
runs-on: ubuntu-latest

actions/run-example/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
name: Run Example App
44
inputs:
55
workspace_name:
6-
description: 'Yarn workspace name of the example app, e.g. @internal/react-sdk-example-client-only'
6+
description: 'Yarn workspace name of the example app'
77
required: true
88
aws_assume_role:
99
description: 'AWS OIDC role ARN used to fetch secrets from SSM'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"packages/sdk/fastly/example",
2121
"packages/sdk/react",
2222
"packages/sdk/react/contract-tests",
23-
"packages/sdk/react/examples/client-only",
23+
"packages/sdk/react/examples/hello-react",
2424
"packages/sdk/react/examples/server-only",
2525
"packages/sdk/react-native",
2626
"packages/sdk/react-native/example",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Have a way to create temporary examples
2+
# for testing and development purposes
3+
temp-*
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# LaunchDarkly React SDK — Examples
2+
3+
This directory contains example applications demonstrating the LaunchDarkly React SDK.
4+
5+
| Example | Description |
6+
|---------|-------------|
7+
| [hello-react](./hello-react/) | Minimal Vite + React app that evaluates a boolean feature flag and displays the result with real-time updates. This is the recommended starting point. |
8+
| [server-only](./server-only/) | Next.js App Router example demonstrating server-side flag evaluation with React Server Components. |

packages/sdk/react/examples/client-only/README.md

Lines changed: 0 additions & 51 deletions
This file was deleted.

packages/sdk/react/examples/client-only/src/App.tsx

Lines changed: 0 additions & 106 deletions
This file was deleted.
File renamed without changes.

packages/sdk/react/examples/client-only/.gitignore renamed to packages/sdk/react/examples/hello-react/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
.env.development.local
1616
.env.test.local
1717
.env.production.local
18+
.env
1819

1920
npm-debug.log*
2021
yarn-debug.log*

0 commit comments

Comments
 (0)