Home Forums Chart Support React example setup error

React example setup error

Viewing 4 posts - 1 through 4 (of 4 total)
  • #22927

    I tried setting up the example from the page https://canvasjs.com/docs/charts/integration/react/
    I have my canvasjs.min.js and canvasjs.react.js in my /src/ folder and getting the following error:

    TypeError: Cannot assign to read only property ‘exports’ of object ‘#<Object>’
    Module.<anonymous>
    C:/Users/jdeangel/Documents/React-Learning/chart_sample/src/canvasjs.react.js:42
    39 | }
    40 | }
    41 |
    > 42 | module.exports = {
    43 | CanvasJSChart: CanvasJSChart,
    44 | CanvasJS: CanvasJS
    45 | };

    Any possible solutions?
    Thank you

    #22928

    @juliandeange,

    Can you please share a sample project over google-drive or one-drive reproducing the issue you are facing, so that we can look into your code, understand the scenario better and help you out?

    __
    Priyanka M S
    Team CanvasJS

    #22943

    Here is my App.js in the src/
    https://codepen.io/juliandeange/pen/vVKbyR

    I also have the canvasjs.react.js and canvasjs.min.js in the src/ folder

    #22954

    @juliandeange,

    The code that you have shared seems to be working fine. Kindly cross-check the path of the script that you have specified in your app.
    1. Save canvasjs.react.js and canvasjs.min.js within source-folder of your React application (src or src/assets or src/lib)
    2. Import canvasjs.react.js to your app. (Please specify proper path of script if you have saved it in different folder like src or src/assets or src/lib)
    import CanvasJSReact from './canvasjs.react';

    Please take a look at this sample project for an working example with proper path.
    React Column Chart

    __
    Priyanka M S
    Team CanvasJS

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

You must be logged in to reply to this topic.