algolia / ui-components

Algolia UI components, available for vanilla JavaScript, React, and Preact.
https://www.algolia.com/
MIT License
13 stars 7 forks source link

[@algolia/ui-components-horizontal-slider-js] `horizontalSlider` not working with `recommend-js` in UMD #1

Open sarahdayan opened 2 years ago

sarahdayan commented 2 years ago

Description

When using ui-components-horizontal-slider-js with recommend-js and both libraries are loaded in UMD, they both import their own bundled version of Preact. Even if the version is the same, the fact that each function uses a different instance of Preact breaks the app.

Reproduction

Preview →

Steps

  1. Visit the sandbox
  2. See the runtime error

Expected behavior

The app should run normally.

Suggested fix

If recommend-js was providing createElement and Fragment in view and that ui-components-horizontal-slider-js accepted a renderer (like autocomplete-js) we could bind the same instance of Preact, which should work.

Environment

Wrubble commented 8 months ago

Hello !

Did any body came up with a solution ? I'm experiencing the same behavior with recommend-js, the documentation indicates :

The horizontalSlider UI component is currently not supported with recommend-js when imported as a UMD bundle https://www.algolia.com/doc/ui-libraries/recommend/api-reference/recommend-js/relatedProducts/#param-view

I couldn't find a workaround for now.

Environment

OS: Windows 11 Browser: Chrome 121.0.6167.162 Library version: @algolia/ui-components-horizontal-slider-js@1.2.2

Haroenv commented 8 months ago

The workaround for now is using a bundler or similar instead of UMD. Sorry!

Wrubble commented 8 months ago

No problem, I eventually managed to display my algolia recommendations in a Swiper.js slider. Thanks for your answer !