Closed GowthamGr closed 5 years ago
The readme has what you're looking for. Use the import statement for React Native and then any of the examples.
Thank you @umpc .
Can you please help to solve this.
I can't help unless you share the version of React Native that you're using and provide all of the relevant code for reproducing the issue.
If you post that info, I would be glad to help.
{ "name": "react_native_chart_kit", "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest" }, "dependencies": { "react": "16.4.1", "react-native": "0.56.0", "react-native-calendar-heatmap": "^0.1.2", "react-native-chart-kit": "^1.1.5", "react-native-heatmap": "^0.1.2", "sunburst.js": "^2.1.1" }, "devDependencies": { "babel-jest": "23.4.2", "babel-preset-react-native": "5.0.2", "jest": "23.4.2", "react-test-renderer": "16.4.1" }, "jest": { "preset": "react-native" } }
//This is my code sunFunc=async()=>{ try { const sunburst = new SunburstJS();
const session = await sunburst.createSession({
email: 'example@example.com',
password: 'hunter2',
type: 'permanent',
scope: ['predictions']
});
console.log(session);
} catch (ex) {
// Handle general network or parsing errors.
return console.error(ex);
}
};
preFunc=async ()=>{ try { const now = new Date(); const thisTimeTomorrow = now.setDate(now.getDate() + 1); const resp = await sunburst.batchQuality([ { geo: [40.7933949, -77.8600012], type: 'sunrise' }, { geo: [40.7933949, -77.8600012], type: 'sunset' }, { geo: [40.7933949, -77.8600012], type: 'sunrise', after: thisTimeTomorrow }, { geo: [40.7933949, -77.8600012], type: 'sunset', after: thisTimeTomorrow } ]); resp.forEach(({ collection, error }) => { if (error) { // Handle individual query errors separately, // as some queries may have still succeeded. return console.error(error); } collection.features.forEach(({ properties }) => { console.log(properties); }); }); } catch (ex) { // Handle general network or parsing errors. return console.error(ex); }};
I can't see where you import the library.
//Yes i imported following
import SunburstJS from 'sunburst.js';
//App.js file import React, {Component} from 'react'; import {Dimensions,Platform, StyleSheet, Text, View} from 'react-native'; import SunburstJS from 'sunburst.js'; //const SunburstJS = require('sunburst.js');
export default class App extends Component
);
}
sunFunc=async()=>{ try { const sunburst = new SunburstJS();
const session = await sunburst.createSession({
email: 'example@example.com',
password: 'hunter2',
type: 'permanent',
scope: ['predictions']
});
console.log(session);
} catch (ex) {
// Handle general network or parsing errors.
return console.error(ex);
}
};
preFunc=async ()=>{ try { const now = new Date(); const thisTimeTomorrow = now.setDate(now.getDate() + 1); const resp = await sunburst.batchQuality([ { geo: [40.7933949, -77.8600012], type: 'sunrise' }, { geo: [40.7933949, -77.8600012], type: 'sunset' }, { geo: [40.7933949, -77.8600012], type: 'sunrise', after: thisTimeTomorrow }, { geo: [40.7933949, -77.8600012], type: 'sunset', after: thisTimeTomorrow } ]); resp.forEach(({ collection, error }) => { if (error) { // Handle individual query errors separately, // as some queries may have still succeeded. return console.error(error); } collection.features.forEach(({ properties }) => { console.log(properties); }); }); } catch (ex) { // Handle general network or parsing errors. return console.error(ex); }}; }
const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, }, });
I can't test this now, though would you try removing the line with the commented require statement?
Expo could be ignoring it while parsing. Just a guess. I will get to this later this week or this weekend.
If this is still an issue, please provide a complete example and I'll be glad to help.
I have the same problem (albeit with nodejs). Looks like the parser modules tries to export the global location
that is only available in browser environments on this line: https://github.com/sunsetwx/sunburst.js/blob/master/src/lib/parsers/params/index.js#L13
@claaslange Thank you for the promising tip. 👍 I will investigate this soon.
@claaslange Let me know if this doesn't fix the issue. A line was missed when we removed a geolocation API before launch.
Thank you for reporting this!
@umpc works like a charm now 👍 Thanks for the quick fix.
Please explain me with working example for react native.