ordering-ui-react-native 0.22.55 → 0.22.56

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.22.55",
3
+ "version": "0.22.56",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -35,7 +35,8 @@ export const ProductOptionSubOptionUI = (props: any) => {
35
35
  disabled,
36
36
  setIsScrollAvailable,
37
37
  image,
38
- enableIntersection
38
+ enableIntersection,
39
+ onChange
39
40
  } = props
40
41
 
41
42
  const disableIncrement = option?.limit_suboptions_by_max ? balance === option?.max || state.quantity === suboption?.max : state.quantity === suboption?.max || (!state.selected && balance === option?.max)
@@ -88,6 +89,12 @@ export const ProductOptionSubOptionUI = (props: any) => {
88
89
  }
89
90
  }, [balance])
90
91
 
92
+ useEffect(() => {
93
+ if (!suboption?.preselected || !option?.respect_to) return
94
+ const newState = { ...state, selected: suboption?.preselected, quantity: state.selected ? 0 : 1 }
95
+ onChange(newState, suboption, option)
96
+ }, [suboption, option])
97
+
91
98
  return (
92
99
  <InView onChange={(inView: boolean) => handleChangeInterSection(inView)} triggerOnce={true}>
93
100
  {isIntersectionObserver ? (