Comments (11)
thank you, it's fixed on v3.4.1
from react-native-calendario.
I hope this will be released as soon as possible, since 3.5.0 is broken and I have to dig into closed issue to find this.
from react-native-calendario.
@anija I think it's already released
from react-native-calendario.
I've tried with v3.4.1 and v3.5.0, both on react-native-months v1.6.3, and I still got the issue. When I select a date in a month and then select another date in another month, the values are not correct, like "onPress" function is wrongly memoized.
from react-native-calendario.
Here is my yarn.lock
react-native-calendario@^3.4.1:
version "3.4.1"
resolved "https://registry.yarnpkg.com/react-native-calendario/-/react-native-calendario-3.4.1.tgz#0520d0061ffe12ab0bb824cc7d1b9b844509d213"
integrity sha512-KdhxgO+HRATf6KHGUExwvv4jaohpkj2vCjNUTacCln2QWwKw4E+ZdVYutEnaWbwP/f+VwiBcsxTPSgnyla4Kpw==
dependencies:
moment "2.29.1"
react-native-month "^1.6.2"
And here is my application that using the feature:
Could you share your code?
from react-native-calendario.
You can succesfully select a startDate in one month and the endDate in the month after?
from react-native-calendario.
@anija Yep!
from react-native-calendario.
Uploading Simulator Screen Recording - iPhone 14 Pro Max - 2023-12-12 at 15.03.44.mp4…
@maggialejandro This week I've caught the same problem on 3.5.0. It looks as the handler for onPress caches a previous state for months which were not rendered in the first render.
I used the fix which set a pressed value to a separate useState and additional useEffect watched for changes.
from react-native-calendario.
Uploading Simulator Screen Recording - iPhone 14 Pro Max - 2023-12-12 at 15.03.44.mp4…
@maggialejandro This week I've caught the same problem on 3.5.0. It looks as the handler for onPress caches a previous state for months which were not rendered in the first render.
I used the fix which set a pressed value to a separate useState and additional useEffect watched for changes.
Hi @mtsymlov, the video didn't finish uploading. What props are you using in the Calendar?
from react-native-calendario.
I've uploaded video to Google Drive.
import React, { useEffect, useState } from 'react'
import { StyleProp, StyleSheet, ViewStyle } from 'react-native'
import Presentation from 'presentation'
import Utils from 'utils'
import { Calendar } from 'react-native-calendario'
import { Box } from 'presentation/components/atoms'
import { Button } from 'presentation/components/moleculas'
const THEME = {
monthTitleTextStyle: {
color: Presentation.Theme.colors['text-secondary'],
fontWeight: '400',
fontSize: 18,
},
emptyMonthContainerStyle: {},
emptyMonthTextStyle: {
fontWeight: '400',
},
weekColumnsContainerStyle: {},
weekColumnStyle: {
paddingVertical: 10,
},
weekColumnTextStyle: {
color: Presentation.Theme.colors['text-secondary-light'],
fontSize: 13,
},
nonTouchableDayContainerStyle: {},
nonTouchableDayTextStyle: {
color: 'white',
},
startDateContainerStyle: {
backgroundColor: Presentation.Theme.colors['background-primary'],
},
endDateContainerStyle: {
backgroundColor: Presentation.Theme.colors['background-primary'],
},
dayContainerStyle: {},
dayTextStyle: {
color: Presentation.Theme.colors['text-basic'],
fontWeight: '300',
fontSize: 16,
},
dayOutOfRangeContainerStyle: {},
dayOutOfRangeTextStyle: {},
todayContainerStyle: {
backgroundColor: Presentation.Theme.colors['background-secondary'],
borderRadius: 1000,
},
todayTextStyle: {
color: Presentation.Theme.colors['text-basic'],
},
activeDayContainerStyle: {
// backgroundColor: Presentation.Theme.colors['background-secondary-light'],
backgroundColor: '#f2f9c8',
},
activeDayTextStyle: {
color: Presentation.Theme.colors['text-basic'],
},
nonTouchableLastMonthDayTextStyle: {},
} as const
const MONTH_HEIGHT = 370 // there was found in the library constants
type CalendarDate = Datestamp | undefined
interface Props {
contentContainerStyles?: StyleProp<ViewStyle>
onChange: (startDate: CalendarDate, endDate: CalendarDate) => void
initialStartDate: CalendarDate
initialEndDate: CalendarDate
}
const FullScreenCalendar: React.FC<Props> = (props) => {
const { contentContainerStyles, initialStartDate, initialEndDate, onChange } = props
const [startDate, setStartDate] = useState<CalendarDate>(initialStartDate)
const [endDate, setEndDate] = useState<CalendarDate>(initialEndDate)
const [pressedDate, setPressedDate] = useState<Date | undefined>()
useEffect(() => {
if (pressedDate) {
const datestamp = Utils.Date.toDatestampFromDate(pressedDate)
if (startDate && endDate) {
if (startDate === endDate && startDate === datestamp) {
setStartDate(undefined)
setEndDate(undefined)
onChange(undefined, undefined)
} else {
setStartDate(datestamp)
setEndDate(undefined)
onChange(datestamp, undefined)
}
} else if (startDate && !endDate) {
if (startDate > datestamp) {
setEndDate(startDate)
setStartDate(datestamp)
onChange(datestamp, startDate)
} else if (startDate === datestamp) {
setStartDate(undefined)
onChange(undefined, endDate)
} else {
setEndDate(datestamp)
onChange(startDate, datestamp)
}
} else if (!startDate && !endDate) {
setStartDate(datestamp)
onChange(datestamp, endDate)
}
setPressedDate(undefined)
}
}, [endDate, onChange, pressedDate, startDate])
const containerStyles = React.useMemo(
() => [contentContainerStyles, styles.ContentContainer],
[contentContainerStyles],
)
return (
<Box>
{(startDate || endDate) && (
<Box position={'absolute'} bottom={120} right={20} zIndex={1000}>
<Button
color={'basic'}
fullWidth={true}
icon={'restore'}
onPress={() => {
setStartDate(undefined)
setEndDate(undefined)
onChange(undefined, undefined)
}}
size={'small'}
title={'Reset'}
/>
</Box>
)}
<Calendar
disableOffsetDays={true}
monthHeight={MONTH_HEIGHT}
firstDayMonday={true}
startingMonth={'2023-01-01'}
numberOfMonths={100}
showsVerticalScrollIndicator={false}
onPress={setPressedDate}
startDate={startDate ? new Date(`${startDate}`) : undefined}
endDate={endDate ? new Date(`${endDate}`) : undefined}
contentContainerStyle={containerStyles}
theme={THEME}
/>
</Box>
)
}
const styles = StyleSheet.create({
ContentContainer: {
paddingTop: 100,
paddingBottom: 200,
paddingHorizontal: Presentation.Theme.screenPadding / 2,
},
})
export default FullScreenCalendar
from react-native-calendario.
@maggialejandro my calendar has 12 months, start_date
and end_date
is today i.e. December is shown below by default. If I select period from June to December it works okay. But if I select period in January it doesn't work properly.
In onPress
handler I see that January contains start_date
and end_date
from first render, even I changed start_date
and end_date
5 times before.
Please feel free to ask me more about environment or something else.
from react-native-calendario.
Related Issues (20)
- UI Freezes when selecting a range of days with `renderDayContent` function. HOT 2
- Visible delay in initial rendering of the Calendar in mobile device HOT 3
- Calendar slides out of view when used in Modal HOT 5
- feature request: prop for `contentContainerStyle` HOT 1
- calculateMonthHeightDynamically disable automatic scroll to startDate HOT 2
- disableOffsetDays theming issue + range issue HOT 4
- Render Issue when startDate and endDate are not in the current month HOT 11
- Custom renderer prop (could be useful for bottom-sheet or flashlist) HOT 4
- Date range selection HOT 4
- The calendar is not clickable in months that are not displayed in the first rendering HOT 3
- Bug with style activeDayContainerStyle HOT 1
- Need Year Selection HOT 4
- Need Range color HOT 1
- Month separator
- Calendar doesn't rerender on markedDates change HOT 3
- Range Selection HOT 7
- Moment.js vunerability issue
- Exception HOT 9
- Types are not match to documentation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-calendario.