In React, execute a function in the parent component by detecting the call of the child component
P粉154798196
P粉154798196 2023-09-10 19:15:14
0
1
720

I need to call a function when a child element of the date picker is clicked

<DropdownParent >
                <DatePicker
                    selectsStart
                    showYearDropdown
                    showMonthDropdown
                    endDate={endDate}
                    selected={startDate}
                    scrollableYearDropdown
                    dateFormat="dd/MM/yyyy"
                    startDate={startDate}
                    yearDropdownItemNumber={10}
                    onChange={(date) => handleChange({ startDateObj: date })}
                    placeholderText={placeholderStart}
                    inline
                    locale="en-gb"
                />
            </DropdownDefaultAtom>

There is a toggle function in DropdownParent, I need to call it when the child function handleChange is called, I tried callbacks and other methods, but since it is a library, I don't know how to detect the change and pass it to the parent component to call the parent function.

P粉154798196
P粉154798196

reply all(1)
P粉470645222

Update the value in Redux, then use it in the change detection of the child component after the value has been updated in Redux, and you can use it throughout the application.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template