Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with React deployments - Segments does not support... #107

Closed
mmontesinoademero opened this issue Jan 24, 2023 · 4 comments
Closed
Assignees

Comments

@mmontesinoademero
Copy link

Everything works great in development, but when deploying my React app, the app is throwing the error "Segments does not support non ordinal color scale" due to the deployed eazychart.esm.js, specifically the call to...

if("ScaleOrdinal"===a.constructor.name)

...which corresponds to line 35 at ez-react/src/components/Segments.tsx.

If I change this to...

a instanceof ScaleOrdinal (eazychart.esm.js)
or
colorScale instanceof ScaleOrdinal (Segments.tsx)

...then everything works as expected. I've not yet dug into see if this is related to my own Babel/Webpack configuration. I've been using the same deployment scripts for many years and never seen anything like this.

@marrouchi
Copy link
Contributor

Hello @mmontesinoademero, thanks for reporting this, we will address the issue as soon as possible :)

@marrouchi
Copy link
Contributor

If I remember correctly we had a typescript issue when using :

a instanceof ScaleOrdinal (eazychart.esm.js)
or
colorScale instanceof ScaleOrdinal (Segments.tsx)

@marrouchi marrouchi self-assigned this Jan 28, 2023
@marrouchi marrouchi mentioned this issue Jan 29, 2023
10 tasks
@marrouchi
Copy link
Contributor

marrouchi commented Jan 29, 2023

@mmontesinoademero The root cause for this issue is well detailed here : https://www.dannyguo.com/blog/how-to-fix-instanceof-not-working-for-custom-errors-in-typescript

The OrdinalScale class extends the AstractScale class and when we perform an "instanceof", in storybook preview :

const scale = new ScaleOrdinal( ... );
console.log(scale instanceof ScaleOrdinal); // prints false
console.log(scale instanceof AbstractScale); // prints true 

This seems to be an issue if when the compilation target is ES3 or ES5, but the wierd thing is that the configured target we have is ESNEXT. "Storybook" relies on Babel and does not account apparently for that config.

TL;DR
We did remove the type safeguard for the moment so that we would think of a better way to handle this in the future : #108 a new release is on the way ;)

@marrouchi
Copy link
Contributor

@mmontesinoademero A new version 0.3.1-alpha.0 has been published, please let us know if you encounter other issues :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants