Skip to content
the poor coder

function runs when click on date react native calendar strip

Poor Man
Published
Reading time
1 min read
On this page

Function Runs When Click on Date React Native Calendar Strip#

If you are using React Native Calendar Strip in your project, you might want to know how to execute a function when the user clicks on a date. Here are two ways you can do it:

1. Using the 'onDateSelected' prop#

The first and easiest way to execute a function when the user clicks on a date in React Native Calendar Strip is by using the 'onDateSelected' prop. This prop is invoked whenever the user selects a date, and it returns the selected date as a moment object.

JavaScript

  <CalendarStrip
    onDateSelected={(date) => {
      // Execute your function here
    }}
  />

In the above code snippet, we have added the 'onDateSelected' prop to the CalendarStrip component, and passed a function as its value. Inside this function, you can write your code that needs to be executed when the user selects a date.

2. Using the 'onWeekChanged' prop#

The second way to execute a function when the user clicks on a date is by using the 'onWeekChanged' prop. This prop is invoked whenever the user changes the week, and it returns an array of moment objects representing the dates in the current week.

JavaScript

  <CalendarStrip
    onWeekChanged={(weekDates) => {
      // Extract the selected date from weekDates array and execute your function here
    }}
  />

In the above code snippet, we have added the 'onWeekChanged' prop to the CalendarStrip component, and passed a function as its value. Inside this function, you can extract the selected date from the 'weekDates' array and execute your code accordingly.

Keep going

2023

how to sort an array

How to Sort an Array If you have an array and you want to order its elements in a specific way, you need to use a sorting algorithm. There are several sorting algorithms available, but two of the most commonly used are…

javascript2 min read
2023

jquery mobile or desktop

jQuery Mobile or Desktop? As a web developer, I have had some experience with both jQuery Mobile and jQuery Desktop. Both frameworks have their pros and cons, and which one to use really depends on the specific project…

javascript1 min read
2023

node.js folder structure

Node.js Folder Structure If you are new to Node.js, it can be daunting to create a folder structure that will work for your project. The structure you choose will depend on the size and complexity of your project. Here…

javascript1 min read
ESC