From cedce4832ab4013ac035b3bfc0b7c3735db6c23b Mon Sep 17 00:00:00 2001 From: lihang Date: Tue, 23 Jan 2018 16:40:13 +0800 Subject: [PATCH] add propTypes, WebView props --- src/components/Echarts/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/components/Echarts/index.js b/src/components/Echarts/index.js index 6ce885f..1050ae3 100644 --- a/src/components/Echarts/index.js +++ b/src/components/Echarts/index.js @@ -2,8 +2,18 @@ import React, { Component } from 'react'; import { WebView, View, StyleSheet } from 'react-native'; import renderChart from './renderChart'; import echarts from './echarts.min'; +import PropTypes from "prop-types"; export default class App extends Component { + static propTypes = { + ...WebView.propTypes, + option: PropTypes.object.isRequired, + width: PropTypes.number, + height: PropTypes.number, + backgroundColor: PropTypes.string, + onPress: PropTypes.func, + } + componentWillReceiveProps(nextProps) { if(nextProps.option !== this.props.option) { this.refs.chart.reload(); @@ -24,6 +34,7 @@ export default class App extends Component { scalesPageToFit={false} source={require('./tpl.html')} onMessage={event => this.props.onPress ? this.props.onPress(JSON.parse(event.nativeEvent.data)) : null} + {...this.props} /> );