How to conditionaly use react component

Hello,

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 ?

Cheers

1 Like

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

E.g.

type t

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

  @module("react-day-picker/DayPicker")
  external picker_: t = "default"
)

let picker = normalize(picker_)

Others might have a cleaner solution.