Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/funny-weeks-stand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@lynx-js/react': minor
---

feat: export `GlobalPropsProvider`, `GlobalPropsConsumer`, `useGlobalProps` and `useGlobalPropsChanged` for `__globalProps`

- `GlobalPropsProvider`: A Provider component that accepts `children`. It is used to provide the `lynx.__globalProps` context.
- `GlobalPropsConsumer`: A Consumer component that accepts a function as a child. It is used to consume the `lynx.__globalProps` context.
- `useGlobalProps`: A hook that returns the `lynx.__globalProps` object. It triggers a re-render when `lynx.__globalProps` changes.
- `useGlobalPropsChanged`: A hook that accepts a callback function. The callback is invoked when `lynx.__globalProps` changes.

Note: When `globalPropsMode` is not set to `'event'` (default is `'reactive'`), these APIs will be ineffective (pass-through) and will log a warning in development mode, as updates are triggered automatically by full re-render.
10 changes: 10 additions & 0 deletions .changeset/thirty-cycles-find.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@lynx-js/react-rsbuild-plugin': minor
Comment thread
HuJean marked this conversation as resolved.
"@lynx-js/react-webpack-plugin": minor
'@lynx-js/react': minor
---

feat: add `globalPropsMode` option to `PluginReactLynxOptions`

- When configured to `"event"`, `updateGlobalProps` will only trigger a global event and skip the `runWithForce` flow.
- Defaults to `"reactive"`, which means `updateGlobalProps` will trigger re-render automatically.
22 changes: 22 additions & 0 deletions packages/react/etc/react.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ export { forwardRef }

export { Fragment }

// @public
export interface GlobalProps {
}

// Warning: (tsdoc-undefined-tag) The TSDoc tag "@group" is not defined in this configuration
//
// @public
export const GlobalPropsConsumer: Consumer<GlobalProps>;

// Warning: (tsdoc-undefined-tag) The TSDoc tag "@group" is not defined in this configuration
//
// @public
export const GlobalPropsProvider: FC<{
children?: ReactNode | undefined;
}>;

// @public
export interface InitData {
}
Expand Down Expand Up @@ -136,6 +152,12 @@ export const useEffect: (effect: EffectCallback, deps?: DependencyList) => void;

export { useErrorBoundary }

// @public
export const useGlobalProps: () => GlobalProps;

// @public
export const useGlobalPropsChanged: (callback: (data: GlobalProps) => void) => void;

export { useImperativeHandle }

// @public
Expand Down
Loading
Loading