@storybook/react-native-ui-lite 10.7.2 → 10.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -381,11 +381,12 @@ const SelectedNodeProvider = ({ children }) => {
381
381
  const scrollCallback = (0, react.useCallback)((options) => {
382
382
  scrollCallbackValue?.(options);
383
383
  }, [scrollCallbackValue]);
384
+ const value = (0, react.useMemo)(() => ({
385
+ scrollCallback,
386
+ registerCallback
387
+ }), [scrollCallback, registerCallback]);
384
388
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectedNodeContext.Provider, {
385
- value: {
386
- scrollCallback,
387
- registerCallback
388
- },
389
+ value,
389
390
  children
390
391
  });
391
392
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native-ui-lite",
3
- "version": "10.7.2",
3
+ "version": "10.7.3",
4
4
  "description": "lightweight ui components for react native storybook",
5
5
  "keywords": [
6
6
  "react",
@@ -32,8 +32,8 @@
32
32
  "@legendapp/list": "^3.3.3",
33
33
  "@nozbe/microfuzz": "^1.0.0",
34
34
  "@storybook/react": "^10.6.7",
35
- "@storybook/react-native-theming": "^10.7.2",
36
- "@storybook/react-native-ui-common": "^10.7.2",
35
+ "@storybook/react-native-theming": "^10.7.3",
36
+ "@storybook/react-native-ui-common": "^10.7.3",
37
37
  "polished": "^4.3.1"
38
38
  },
39
39
  "devDependencies": {
@@ -1,5 +1,5 @@
1
1
  import type { FC, PropsWithChildren } from 'react';
2
- import { createContext, useCallback, useContext, useState } from 'react';
2
+ import { createContext, useCallback, useContext, useMemo, useState } from 'react';
3
3
  type CallbackOptions = { id?: string; animated?: boolean };
4
4
 
5
5
  type SelectedNodeContextType = {
@@ -28,16 +28,13 @@ export const SelectedNodeProvider: FC<PropsWithChildren> = ({ children }) => {
28
28
  [scrollCallbackValue]
29
29
  );
30
30
 
31
- return (
32
- <SelectedNodeContext.Provider
33
- value={{
34
- scrollCallback,
35
- registerCallback,
36
- }}
37
- >
38
- {children}
39
- </SelectedNodeContext.Provider>
31
+ // Keep the value stable between renders, so its consumers re-render only when it changes.
32
+ const value = useMemo(
33
+ () => ({ scrollCallback, registerCallback }),
34
+ [scrollCallback, registerCallback]
40
35
  );
36
+
37
+ return <SelectedNodeContext.Provider value={value}>{children}</SelectedNodeContext.Provider>;
41
38
  };
42
39
 
43
40
  export const useSelectedNode = () => useContext(SelectedNodeContext);