Code Monkey home page Code Monkey logo

Comments (4)

aldiinugroho avatar aldiinugroho commented on June 17, 2024 7

maybe dates.displayedDate will be undefined, therefore we need to give certain conditions.

try this maybe it help:

const setDates = (dates) => {
        if (dates.startDate != undefined) {
            setStartDate(dates.startDate)
        }

        if (dates.displayedDate != undefined) {
            setDisplayedDate(dates.displayedDate)
        }

        if (dates.endDate != undefined) {
            setEndDate(dates.endDate)
        }
    };

from react-native-daterange-picker.

johnny-minty avatar johnny-minty commented on June 17, 2024

@longman0512 You need to ensure you handle the onChange event properly and set/update the 'displayedDate' prop correctly

from react-native-daterange-picker.

fcamargo10 avatar fcamargo10 commented on June 17, 2024

maybe dates.displayedDate will be undefined, therefore we need to give certain conditions.

try this maybe it help:

const setDates = (dates) => {
        if (dates.startDate != undefined) {
            setStartDate(dates.startDate)
        }

        if (dates.displayedDate != undefined) {
            setDisplayedDate(dates.displayedDate)
        }

        if (dates.endDate != undefined) {
            setEndDate(dates.endDate)
        }
    };

Work's fine.

from react-native-daterange-picker.

shoaibshebi avatar shoaibshebi commented on June 17, 2024

Set Like that

👇👇😊

const [dateObj, setDateObj] = useState({
    startDate: null,
    endDate: null,
    displayedDate: moment(),
  });
  
  
<DateRangePicker
            onChange={dates => {
              console.log('dates ------------------', dates);
              setDateObj({
                startDate:
                  'startDate' in dates
                    ? moment(dates.startDate)
                    : dateObj?.startDate,
                endDate:
                  'endDate' in dates ? moment(dates.endDate) : dateObj?.endDate,
                displayedDate:
                  'displayedDate' in dates
                    ? moment(dates.displayedDate)
                    : dateObj?.displayedDate,
              });
            }}
            endDate={dateObj?.endDate}
            startDate={dateObj?.startDate}
            displayedDate={dateObj?.displayedDate}
            range={true}
>

from react-native-daterange-picker.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.