-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
130 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
e2e/nextjs/app-router/app/app/normal/ConditionalClientComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use client' | ||
|
||
export default function ConditionalClientComponent() { | ||
return ( | ||
<div> | ||
<h1>Client Component Conditionally Bundled</h1> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
import { setupDevCycle } from '@devcycle/nextjs-sdk/server' | ||
import { headers } from 'next/headers' | ||
const { getVariableValue, getClientContext, getAllVariables, getAllFeatures } = | ||
setupDevCycle( | ||
process.env.NEXT_PUBLIC_E2E_NEXTJS_KEY ?? '', | ||
async () => { | ||
const reqHeaders = headers() | ||
return { | ||
user_id: '123', | ||
customData: { | ||
// set a dummy field here so that the headers call stays in the build output | ||
someKey: reqHeaders.get('some-key'), | ||
}, | ||
} | ||
}, | ||
{ enableStreaming: false }, | ||
) | ||
|
||
export { getVariableValue, getClientContext, getAllVariables, getAllFeatures } | ||
export const { | ||
getVariableValue, | ||
getClientContext, | ||
getAllVariables, | ||
getAllFeatures, | ||
} = setupDevCycle( | ||
process.env.NEXT_PUBLIC_E2E_NEXTJS_KEY ?? '', | ||
async () => { | ||
const reqHeaders = headers() | ||
return { | ||
user_id: '123', | ||
customData: { | ||
// set a dummy field here so that the headers call stays in the build output | ||
someKey: reqHeaders.get('some-key'), | ||
}, | ||
} | ||
}, | ||
{ enableStreaming: false }, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
// Use this file to export React client code (e.g. those with 'use client' directive) | ||
// or other non-server utilities | ||
export * from './src/client/useVariableValue' | ||
export * from './src/client/DevCycleClientsideProvider' | ||
export * from './src/common/types' | ||
export * from './src/client/useUserIdentity' | ||
export * from './src/client/useTrack' | ||
export * from './src/client/useAllVariables' | ||
export * from './src/client/useAllFeatures' | ||
export { useVariable, useVariableValue } from './src/client/useVariableValue' | ||
export type * from './src/common/types' | ||
export { useUserIdentity } from './src/client/useUserIdentity' | ||
export { useTrack } from './src/client/useTrack' | ||
export { useAllVariables } from './src/client/useAllVariables' | ||
export { useAllFeatures } from './src/client/useAllFeatures' | ||
export { renderIfEnabled } from './src/client/renderIfEnabled' | ||
export { DevCycleClientsideProvider } from './src/client/DevCycleClientsideProvider' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { ComponentProps, ComponentType } from 'react' | ||
import dynamic from 'next/dynamic' | ||
import useVariableValue from './useVariableValue' | ||
|
||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
export const renderIfEnabled = <T extends { default: ComponentType<any> }>( | ||
key: string, | ||
importFunc: () => Promise<T>, | ||
) => { | ||
const Component = dynamic(() => importFunc()) | ||
return function (props: ComponentProps<T['default']>) { | ||
const isEnabled = useVariableValue(key, false) | ||
if (isEnabled) { | ||
return <Component {...props} /> | ||
} | ||
return null | ||
} | ||
} |
File renamed without changes.
57ab969
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
js-sdks-with-provider – ./
dvc-with-provider.vercel.app
js-sdks-with-provider-git-main-devcyclehq.vercel.app
js-sdks-with-provider-devcyclehq.vercel.app
57ab969
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
js-sdks-web-elements – ./
js-sdks-web-elements-devcyclehq.vercel.app
js-sdks-web-elements.vercel.app
js-sdks-web-elements-git-main-devcyclehq.vercel.app