【发布时间】:2018-11-12 11:33:47
【问题描述】:
我编写了一个移动应用程序,通过使用 react-native 从用户那里收集一些数据。它使用react native 0.57.4、react 16.2.0、react-redux 5.0.5、prop-types 15.5.10,、react-navigation 1.0.0-beta.11。我还使用this library 在 Web 视图中创建调查问题,即基本上将包含 SurveyJS 调查的 Web 视图嵌套在 React Native 应用程序中。Package.JSON
{
"name": "SurveyJSInWebViewWithReactAndReactNative",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"lodash": "^4.17.11",
"moment": "^2.20.1",
"prop-types": "15.5.10",
"react": "16.2.0",
"react-native": "^0.57.4",
"react-native-webview-bridge": "git+https://github.com/abolger/react-native-webview-bridge.git",
"react-navigation": "1.0.0-beta.11",
"react-redux": "5.0.5",
"redux": "3.7.1"
},
"devDependencies": {
"babel-jest": "22.1.0",
"babel-preset-react-native": "5.0.2",
"jest": "22.1.2",
"native-base": "^2.8.1",
"react-test-renderer": "16.2.0"
},
"jest": {
"preset": "react-native"
}
}
app.js
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View
} from 'react-native';
import surveys from './survey/default_surveys';
import Survey from './survey';
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' +
'Cmd+D or shake for dev menu',
android: 'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});
export default class App extends Component<{}> {
onSurveyCompleted(ownProps, nextProps) {
//TODO: Readers hooks go here.
alert("Nested Survey was completed!");
}
render() {
return (
<Survey
surveyJSON={surveys.example3PagePatientSatisfactionSurvey}
title="My Custom Survey Title"
navigation={this.props.navigation}
surveyResponseDateString={''}
onSurveyComplete={this.onSurveyCompleted}
data={{}}/>
);
}
}
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,
},
});
【问题讨论】:
标签: javascript reactjs react-native