forked from imtoo/meetup-iOS-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChartView.js
42 lines (33 loc) · 1.01 KB
/
ChartView.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// @flow
/* eslint-disable react/prefer-stateless-function */
import React, { Component } from 'react';
import { NativeEventEmitter, NativeModules, requireNativeComponent } from 'react-native';
const { NotificationCenterData } = NativeModules;
const NCEventEmitter = new NativeEventEmitter(NotificationCenterData);
const NCEventName = 'NCPeriodicalData';
const ncSubscription = NCEventEmitter.addListener(
NCEventName,
(data: string[]) => console.log('NC data: ', data),
);
const MODULE_NAME = 'ChartView';
const Chart = requireNativeComponent(MODULE_NAME, null);
type PropsType = {|
+xValues: string[],
+yValues: number[],
|};
class ChartView extends Component<PropsType> {
componentWillUnmount() {
ncSubscription.remove();
}
render() {
const { xValues, yValues } = this.props;
return (
<Chart
xValues={xValues}
yValues={yValues}
style={{ flex: 1 }}
/>
);
}
}
export default ChartView;