0

I just upgraded chart.js at v4.1 and react-chartjs-2 at v5.1, in order to use react 18, in my components library. After I installed my version which includes the updated packages, I get the following error: TypeError: Cannot read properties of undefined (reading 'register'). Do you have any idea why this is happening? Before the upgrade, everything worked and also, in my components library, I have some examples using Chart components that are working as expected. Thanks! ErrorImage This is my code:

import { Chart as BaseChart } from 'react-chartjs-2'
import { Chart as ChartJS } from 'chart.js/auto'
import { CategoryScale, LinearScale, PointElement, LineElement, BarElement } from 'chart.js'

ChartJS.register(CategoryScale, LinearScale, PointElement, LineElement, BarElement)
2
  • 1
    Please provide enough code so others can better understand or reproduce the problem. Commented Feb 12, 2023 at 8:39
  • react-chartjs-2.js.org/#quickstart Commented Feb 13, 2023 at 12:51

1 Answer 1

-1

It worked after I downgraded to chart.js v3.9.1 and react-chartjs-2 at v4.3.1

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.