-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
state_descriptors_fixed occurs when object is enumerable
, configurable
and writable
and has value
#15607
Comments
Please provide a minimal reproduction, your whole project is not minimal and it would take us much more time than you to create a minimal one we can work on |
<script lang="ts">
import { onMount, onDestroy } from 'svelte';
import Chart, { registerables } from 'chart.js/auto';
import months from '../../stories/utils/months.js';
import type { ChartData, ChartOptions } from 'chart.js';
const type = 'bar';
const labels = months({ count: 7 });
const data: ChartData = $state({
labels: labels,
datasets: [
{
label: 'My First Dataset',
data: [65, 59, 80, 81, 56, 55, 40],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(255, 159, 64, 0.2)',
'rgba(255, 205, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(201, 203, 207, 0.2)'
],
borderColor: [
'rgb(255, 99, 132)',
'rgb(255, 159, 64)',
'rgb(255, 205, 86)',
'rgb(75, 192, 192)',
'rgb(54, 162, 235)',
'rgb(153, 102, 255)',
'rgb(201, 203, 207)'
],
borderWidth: 1
}
]
});
const options: ChartOptions = {
scales: {
y: {
beginAtZero: true
}
}
};
const updateMode = 'default';
let canvasRef: HTMLCanvasElement | null = $state(null);
let chart: Chart | null = null;
onMount(() => {
Chart.register(...registerables);
if (canvasRef) {
chart = new Chart(canvasRef, {
type,
data,
options
});
}
});
$effect(() => {
if (!chart) return;
chart.data = data;
Object.assign(chart.options, options);
chart.update(updateMode);
});
onDestroy(() => {
if (chart) chart.destroy();
chart = null;
});
</script>
<canvas bind:this={canvasRef}></canvas>
<style>
canvas {
max-width: 100%;
}
</style> |
The only case where I see |
Thank you! That solved the issue. |
Describe the bug
I'm trying to make a wrapper for Chart.js. When there is data is passed as plain non-$state prop, it works fine. But when data is defined to be reactive with $state, the chart doesn't error due to the following error in the log section. This causes problem in Vitest and Storybook, making them unusable.
Reproduction
Clone https://github.com/sveltejs-labs/Chart.js and run
npm run dev
with browser developer console opened. It will print the properties of data object and printLogs
System Info
Severity
blocking all usage of svelte
The text was updated successfully, but these errors were encountered: