【发布时间】:2017-08-22 21:20:40
【问题描述】:
import React, { Component } from 'react';
import {
AppRegistry,
Button,
StyleSheet,
View,
requireNativeComponent,
} from 'react-native';
import Sketch from 'react-native-sketch';
const styles = StyleSheet.create({
container: {
flex: 1,
},
sketch: {
height: 250, // Height needed; Default: 200px
},
});
export default class paintChalledgeNative extends Component {
constructor(props) {
super(props);
this.clear = this.clear.bind(this);
this.onReset = this.onReset.bind(this);
this.onSave = this.onSave.bind(this);
this.onUpdate = this.onUpdate.bind(this);
this.state = {
drawing: null,
};
}
onReset() {
console.log('bye bye drawing');
}
onSave() {
this.sketch.saveImage(this.state.drawing)
.then(data => console.log(data))
.catch(error => console.log(error));
}
onUpdate(base64Image) {
this.setState({ drawing: base64Image });
}
clear() {
this.sketch.clear();
}
render() {
return (
<View style={styles.container}>
<Sketch
fillColor="transparent"
strokeColor="#111111"
strokeThickness={2}
imageType="png"
onReset={this.onReset}
onUpdate={this.onUpdate}
ref={(sketch) => { this.sketch = sketch; }}
style={styles.sketch}
/>
<Button
onPress={this.clear}
title="clear drawing"
/>
<Button
disabled={!this.state.encodedSignature}
onPress={this.onSave}
title="Save drawing"
/>
</View>
);
}
}
AppRegistry.registerComponent('paintChalledgeNative', () => paintChalledgeNative);
使用“react-native-sketch”构建草图应用程序,模拟器正在运行,但草图功能根本没有工作,清除按钮使应用程序崩溃并出现图像错误,控制台正在记录 20 个类似的错误消息下面的那个 '在 /Users/waltershub/Desktop/paintChalledgeNative/node_modules/react-native-sketch/RNSketch/RNSketch.m:11 中包含的文件中: ../react-native/React/Base/RCTEventDispatcher.h:18:3:错误:重新定义枚举器“RCTTextEventTypeChange” RCTTextEventTypeChange,'
【问题讨论】:
标签: javascript xcode react-native