Skip to content

Is there anyway to use this library in a project which is initialized by Expo & using Typescript template? #136

@ngmikeng

Description

@ngmikeng

I know this library is deprecated but hope someone has also met the issue.
I tried following the instruction but it doesn't work.

My steps:

  • Install package by yarn
  • Create file metro.config.js
  • Install react-native-webview by yarn
  • Put some //@ts-ignore in code for ignore type checking
  • Try with the example code in a component
import React, { useEffect, useState } from "react";
import { View, StyleSheet } from "react-native";
// @ts-ignore
import HighchartsReactNative from "@highcharts/highcharts-react-native";

const Chart: React.FC = () => {
  const [chartOptions, setChartOptions] = useState<any>();

  useEffect(() => {
    let intervalId: NodeJS.Timer;
    const chartOptionsTest = {
      chart: {
        events: {
          load: function () {
            // @ts-ignore
            // set up the updating of the chart each second
            const series = this.series[0];
            intervalId = setInterval(function () {
              const y = Math.random();
              series.addPoint(y, true, true);
            }, 1000);
          }
        }
      },
      series: [{
        data: [1, 2, 3]
      }]
    }
    setChartOptions(chartOptionsTest);

    return () => {
      if (intervalId) {
        clearInterval(intervalId);
      }
    }
  }, [])

  return (
    <View style={styles.container}>
      <HighchartsReactNative
        styles={styles.container}
        options={chartOptions}
      />
    </View>
  )
}

const styles = StyleSheet.create({
  container: {
    backgroundColor: '#fff',
    justifyContent: 'center',
    flex: 1
  }
});

export default Chart;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions