react-google-charts is a fully typed React component library that provides a lightweight wrapper around the official Google Charts library. It simplifies the integration of over 25 different Google Chart types, supporting animations and extensive customization options. The package is currently at version 5.2.1 and shows an active release cadence with frequent updates, including new features, bug fixes, and typings enhancements, as evidenced by recent 5.x releases. Its primary differentiator is providing a modern React component API with TypeScript support, abstracting away the direct interaction with the Google Charts loader script and API, making it easier for React developers to quickly add data visualizations to their applications without deep knowledge of the underlying Google Charts library.
npm install react-google-chartsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to render a basic Line Chart using `react-google-charts`, providing data and options.
Ensure your project is configured to handle ES Modules and your target browser environment is modern. Update your import statements from CommonJS `require()` to ESM `import`.
Upgrade to v5.1.0 or newer to benefit from the fix that uses `useEffect` for managing event listeners. This ensures proper cleanup and re-initialization.
Update to version 5.0.0 or later, which includes fixes to ensure charts re-draw reliably on relevant prop changes, including data, columns, and rows.
Upgrade to version 4.0.6 or newer, which includes mitigations for the infinite loading issue. If the problem persists, ensure no other scripts are interfering with Google's `loader.js`.
If you relied on `charteditor`, you might need to explicitly load it or review alternative solutions if your use case requires it. Check the updated documentation for guidance.
Change your import statement from `import Chart from 'react-google-charts';` to `import { Chart } from 'react-google-charts';`.Ensure that `google.charts.load` is called only once with a consistent configuration across your application. You might need to coordinate loading or use a single top-level `Chart` component to manage the loader.
Always provide a valid `chartType` prop, e.g., `<Chart chartType="BarChart" ... />`.
Ensure your `data` prop is an array of arrays, with the first inner array typically being the column headers and subsequent arrays being the data rows, e.g., `data={[['x', 'y'], [1, 2], [3, 4]]}`.