react-flatpickr icon indicating copy to clipboard operation
react-flatpickr copied to clipboard

Flatpickr instance is available at `flatpickr` rather than `_flatpickr` as main docs say

Open jakeparis opened this issue 9 months ago • 0 comments

The main docs for Flatpickr say that the instance can be accessed on the dom element at the _flatpickr property https://flatpickr.js.org/instance-methods-properties-elements/#retrieving-the-flatpickr-instance

However, when trying to access the instance when using this React library, it seems only available at flatpickr (without the leading underscore). This should probably be fixed for consistency.

Example:

const fp = useRef(null)

useEffect(()=>{
  // According to the Flatpickr docs, I'd expect the flatpickr instance available like this:
  fp.current._flatpickr.set( 'allowInput', true );
  // but instead, it needs to be accessed like this:
  fp.current.flatpickr.set( 'allowinput', true );

}, [ somethingElse ] );

return (
  <Flatpickr ref={fp} />
);

jakeparis avatar May 09 '24 15:05 jakeparis