Repository navigation
Closed
Description
Having an overlay with an EuiDatePicker (using formik and yup for form control), I seem to run into issues with findDOMNode (when in Strict mode). Somewhere, depending on the code path, it seems there are still references to DOM Nodes. Can this be fixed?
DatePicker.js#L17-27:
const DatePicker = ({date, changeDateTo}) => {
const {i18n} = useTranslation()
return (
<EuiDatePicker
selected={date}
onChange={changeDateTo}
adjustDateOnChange={false}
dateFormat={'DD MMM YYYY '}
locale={i18n.language} />
)
}
ChooseActivityDateForm.js#L89-99:
export default ({formik}) => {
const changeDateTo = date => {
formik.setFieldValue('calendar.date', date)
}
const date = formik.values.calendar.date;
return (
<EuiFlexGroup>
<EuiFlexItem>
<DatePicker date={date}
changeDateTo={changeDateTo} />
</EuiFlexItem>
results in:
Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Calendar which is inside StrictMode. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://fb.me/react-strict-mode-find-node
in div (created by CalendarContainer)
in CalendarContainer (created by Calendar)
in Calendar (created by OnClickOutside(Calendar))
in OnClickOutside(Calendar) (created by DatePicker)
in div (created by InnerPopper)
in InnerPopper (created by Context.Consumer)
in Popper$1 (created by PopperComponent)
in Manager (created by PopperComponent)
in PopperComponent (created by DatePicker)
in DatePicker (created by Context.Consumer)
in EuiValidatableControl (created by EuiDatePicker)
in div (created by EuiFormControlLayout)
in div (created by EuiFormControlLayout)
in EuiFormControlLayout (created by EuiDatePicker)
in span (created by EuiDatePicker)
in span (created by EuiDatePicker)
in EuiDatePicker (at ChooseActivityDateForm.js:20)
in DatePicker (at ChooseActivityDateForm.js:97)
in div (created by EuiFlexItem)
in EuiFlexItem (at ChooseActivityDateForm.js:96)
in div (created by EuiFlexGroup)
in EuiFlexGroup (at ChooseActivityDateForm.js:95)
in Unknown (at AddActivityForm.js:47)
in div (created by EuiFlexItem)
...
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]findDOMNode is deprecated in StrictMode. in EuiDatePicker[/-][+][EuiDatePicker] findDOMNode is deprecated in StrictMode. in EuiDatePicker[/+]kurt-o-sys commentedon Aug 4, 2020
Checking the code, there seem to be 2 calls to
findDOMNodein theEuiDatePicker. It is in theonClickOutsidefunction, or rather inonClickOutsideHOCofreact-datepicker.js#L1247-1274:I guess, here's a problem depending on where/how the
EuiDatePickeris used:react-datepicker.js#L1234So, I suppose there may be two solutions:
findDOMNodeshouldn't be used.Strictmode - I didn't test/try yet, but probably the component using the datepicker may need to add someuseRef?@thompsongl Any hints/ideas how to solve the
findDOMNodewarning?chandlerprall commentedon Aug 4, 2020
Thanks for digging through the code on this! We use a vendored version of
react-datepicker, where we "forked" that project but keep the files within the EUI repo https://github.com/elastic/eui/tree/master/packages/react-datepickerThat code relies on
react-onclickoutside@^6.7.1which is where thefindDOMNodecall comes from. That project's most recent version still uses findDOMNode. There is an issue which mentions the need to removefindDOMNode, but I don't see indication that the project will be updated to avoid it. Which means EUI needs to further modify our react-datepicker fork to use another solution. We do have our own EuiOutsideClickDetector component, but there isn't a way to use that component from within the react-datepicker project.thompsongl commentedon Aug 10, 2020
Haven't explored this at all, but I wonder if the idea suggested in #3476 (use the inline datepicker inside of EuiPopover) would help here.