张昕伟
张昕伟

Reputation: 134

Dynamically assign the text content of a certain day in react-native-calendars

eg. when I click the date “ March, 7th ” ,the text “21 days” will appear on 21 days later date in calendar instead of "March,28th”.

enter image description here

Upvotes: 0

Views: 3904

Answers (1)

Mikayel Saghyan
Mikayel Saghyan

Reputation: 738

You probably should create a new Day Component for what you need.

  1. You can create a new Day Component inside the react native calendar: react-native-calendars/src/calendar/day/
  2. You can create a new Day Component using the API of the react native calendar, check the documentation for it here https://github.com/wix/react-native-calendars#overriding-day-component:

    dayComponent={({date, state}) => { return (customDayComponent); }}

Or without day component you will have to get the left and top position of the needed day and place an overlaying View over the day (position: 'absolute', zIndex: 1).

Upvotes: 2

Related Questions