highcharts-react-native icon indicating copy to clipboard operation
highcharts-react-native copied to clipboard

Bundle issue: `@highcharts/HighchartsReactNative` does not exist in the Haste

Open aliceathens opened this issue 7 years ago • 16 comments

error: bundling failed: Error: Unable to resolve module `@highcharts/HighchartsReactNative` from `...`: Module `@highcharts/HighchartsReactNative` does not exist in the Haste module map

"@highcharts/highcharts-react-native": "^1.0.0",
    "react": "16.8.3",
    "react-native": "0.59.10",

node -v: v11.0.0 npm -v : 6.11.3

This is using an ejected RN app building via command line. I have tried clearing all cache etc re installed node_modules etc.

aliceathens avatar Sep 06 '19 05:09 aliceathens

The main repo is demo expo application, but if you need only Highcharts-react-native package, you should clone only the dist folder and then call npm install or yarn.

sebastianbochan avatar Sep 06 '19 08:09 sebastianbochan

check if node_modules\@highcharts\HighchartsReactNative exists For mine, it is node_modules\@highcharts\highcharts-react-native So I change import HighchartsReactNative from '@highcharts/HighchartsReactNative'; to import HighchartsReactNative from '@highcharts/highcharts-react-native';

I don't know if it is an appropriate way to do, but no error right now.

ms042087 avatar Sep 07 '19 09:09 ms042087

+1

waleedarshad avatar Sep 29 '19 11:09 waleedarshad

I ran yarn add @highcharts/highcharts-react-native in a react-native project and tried to run the below piece of code (which is the first example provided in the readme) and replaced the import with @highcharts/highcharts-react-native as suggested above but nothing draws on the screen. However when cloning the beta-webview branch and running the exact same piece of code I can see the chart.

How do you recommend adding this library to a RN project?

import React from 'react';
import {
    StyleSheet,
    View
} from 'react-native';
import HighchartsReactNative from '@highcharts/highcharts-react-native';

export default class App extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            chartOptions: {
                series: [{
                    data: [1, 3, 2]
                }]
            }
        };
    }

    render() {
        return (
            <View>
                <HighchartsReactNative
                    styles={styles.container}
                    options={this.state.chartOptions}
                />
            </View>
        );
    }
}

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

fredpinon avatar Oct 05 '19 09:10 fredpinon

@fredpinon I am also getting a blank chart.

Do you know what issue is the beta-webview branch addressing? I am suddenly experiencing blank charts in another expo app that uses a different charting library. That app has been rendering charts properly for months.

athenawisdoms avatar Oct 05 '19 17:10 athenawisdoms

@fredpinon I did not publish it in npm, so at this moment I recommend to download beta-webview, and use package by import HighchartsReactNative from path/to/the/beta-webview, like you mentioned.

sebastianbochan avatar Oct 07 '19 12:10 sebastianbochan

@sebastianbochan, thanks for getting back to me. I am doing what you described at the moment to test out the library, very happy with the performance, but I am struggling to update a chart, even when using the readme example shown under optimal way to update. Is it worth opening an issue for this or are you already aware of the problem. I hope to find out why this is happening and maybe open a pr. If you have an idea of when the current changes will be merged in master that would be great to know as well. Cheers! Fred

fredpinon avatar Oct 08 '19 10:10 fredpinon

@fredpinon Hi Fred. I have problem in updating the chart too. The chart can be updated successfully using Math.random in the setInterval function in this.state.option, but I can't figure it out how to update the chart using data which is fetched from API. May I know more about your issue?

ms042087 avatar Oct 08 '19 12:10 ms042087

I was not aware of that, so thank you. Do you call chart.update() with any specific options? Could you post it?

sebastianbochan avatar Oct 08 '19 13:10 sebastianbochan

@sebastianbochan, I simply copy pasted that example but pressing on the Chart update button did not update it. This seems to be because the new chart options are never injected in the webview. The existing injectedJavaScript prop only runs once when the page loads for the first time. Don't know if that's the best way to fix it but adding that piece of code in componentDidUpdate did update the chart:

this.webView.injectJavaScript(
    `Highcharts.chart("container", ${this.serialize(
        this.props.options,
        true,
    )}); true;`,
);

Glad to open a pr. And possibly another one to add the possibility for the wrapper to accept optional onMessage and onLoadEnd props which it would pass to the WebView. Cheers, Fred

fredpinon avatar Oct 08 '19 13:10 fredpinon

@fredpinon its not a good option, because the performance will not be good (destroy-chart and create new one is not always efficient. Its the last solutution, if others will fail). I will debug it and will let you know about results.

sebastianbochan avatar Oct 08 '19 13:10 sebastianbochan

The new version (2.0.2) has been already released and update works properly.

Im closing the ticket, but please reopen if any issues will come again.

sebastianbochan avatar Nov 25 '19 12:11 sebastianbochan

Simulator Screen Shot - iPhone 11 Pro Max - 2020-10-25 at 12 42 52

I got this error, I think there is nothing wrong in file path. I'm new to react-native is there anything do I need to take care? Help me resolve this.

banuharshavardhan avatar Oct 25 '20 07:10 banuharshavardhan

It is required to add the .hcscript into the asset extensions section of metro.config.js file, or create that file within your project.

You can find more information about setup in our docs here: https://github.com/highcharts/highcharts-react-native#installing

sebastianbochan avatar Oct 26 '20 12:10 sebastianbochan

@ManelGonzalez-ops I faced the same problem with HighCharts and it was really frustrating to see generic steps like the ones on the documentation page. To fix the issue, just create a file named metro.config.js in your project root folder and add the snippet mentioned on the documentation page , i.e. the following code into the file:

const {getDefaultConfig} = require('metro-config');

module.exports = (async () => { const { resolver: { sourceExts, assetExts } } = await getDefaultConfig() return { transformer: { getTransformOptions: async () => ({ transform: { experimentalImportSupport: false, inlineRequires: false } }) }, resolver: { sourceExts, assetExts: [...assetExts, 'hcscript'] } } })()

Hope this helps!

HrushikeshChoudhary avatar Dec 07 '20 19:12 HrushikeshChoudhary