How to conditionaly use react component


I have an issue with Vite and a specific module (react-day-picker) based on the import. One of the hotfix is to manually check if the module expose default or not.

import _Picker from 'react-day-picker/DayPicker'
const Picker = _Picker.default || _Picker;

What would be the best way to handle this ?


1 Like

I wonder if this might be a good use case for %raw?


type t

  let normalize: t => t = %raw(`t => t.default || t`)

  external picker_: t = "default"

let picker = normalize(picker_)

Others might have a cleaner solution.