Home forums Using CanvasJS Cannot import to React

Tagged: 

This topic contains 3 replies, has 3 voices, and was last updated by  Manoj Mohan 1 week, 3 days ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #27248

    Hi,

    I’m trying to create a React app and I followed the instructions posted. But I keep getting this error:
    ./src/index.js
    Attempted import error: ‘CanvasJS’ is not exported from ‘./canvasjs.react’ (imported as ‘CanvasJSReact’).

    what am i doing wrong?

    #27256

    @meg_lai,

    Please take a look at this sample project for integrating CanvasJS with React.

    If you are still facing the issue, kindly share a sample project reproducing the issue over google-drive or one-drive so that we can look into the code, understand the scenario better and help you out.

    —–
    Manoj Mohan
    Team CanvasJS

    #27360

    Hi Guys,

    Yes, meg_lai is correct. Your demos are not working.

    The code below is now the correct way to import.

    import CanvasJSReact from '../../assets/canvasjs.react.js';
    var CanvasJSChart = CanvasJSReact.CanvasJSChart;
    #27368

    @saulable,

    The download sample seems to be working fine. Providing proper relative path for canvasjs.react.js file should work fine in your case.

    —-
    Manoj Mohan
    Team CanvasJS

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.