diff --git a/src/components/DaySelector.tsx b/src/components/DaySelector.tsx index 19cf5ae..de46e34 100644 --- a/src/components/DaySelector.tsx +++ b/src/components/DaySelector.tsx @@ -9,9 +9,11 @@ const DaySelector = () => { const month = utils.getDateMonth(currentDate); const year = utils.getDateYear(currentDate); const days = useMemo( - () => utils.getMonthDays(currentDate), + () => { + return utils.getMonthDays(currentDate); + }, // eslint-disable-next-line react-hooks/exhaustive-deps - [month, year, utils.displayFullDays] + [month, year, utils.displayFullDays, utils.minimumDate, utils.maximumDate] ); const handleSelectDate = (date: string) => { @@ -135,7 +137,6 @@ const styles = StyleSheet.create({ height: '100%', flexWrap: 'wrap', flexDirection: 'row', - justifyContent: 'center', alignContent: 'flex-start', }, dayCell: { diff --git a/src/components/TimePicker/Wheel.tsx b/src/components/TimePicker/Wheel.tsx index 12eafa1..b3731c1 100644 --- a/src/components/TimePicker/Wheel.tsx +++ b/src/components/TimePicker/Wheel.tsx @@ -7,7 +7,7 @@ import { ViewStyle, Platform, } from 'react-native'; -import React, { useMemo, useRef } from 'react'; +import React, { memo, useMemo, useRef } from 'react'; import { sin } from './AnimatedMath'; import { CALENDAR_HEIGHT } from '../../enums'; @@ -28,7 +28,7 @@ export interface WheelProps extends WheelStyleProps { onScroll?: (scrollState: boolean) => void; } -export default function Wheel({ +const Wheel = ({ value, setValue, onScroll, @@ -40,7 +40,7 @@ export default function Wheel({ disabledColor = 'gray', wheelHeight, displayCount = 5, -}: WheelProps) { +}: WheelProps) => { const translateY = useRef(new Animated.Value(0)).current; const renderCount = displayCount * 2 < items.length @@ -100,7 +100,7 @@ export default function Wheel({ const displayValues = useMemo(() => { const centerIndex = Math.floor(renderCount / 2); - return [...Array(renderCount).keys()].map((_, index) => { + return Array.from({ length: renderCount }, (_, index) => { let targetIndex = valueIndex + index - centerIndex; if (targetIndex < 0 || targetIndex >= items.length) { targetIndex = (targetIndex + items.length) % items.length; @@ -136,7 +136,7 @@ export default function Wheel({ style={[styles.container, containerStyle]} {...panResponder.panHandlers} > - {displayValues.map((displayValue, index) => { + {displayValues?.map((displayValue, index) => { const animatedAngle = animatedAngles[index]; return ( ); -} +}; const styles = StyleSheet.create({ container: { @@ -199,3 +199,5 @@ const styles = StyleSheet.create({ alignItems: 'center', }, }); + +export default memo(Wheel);