首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >react-native-sketch模块和组件根本不起作用

react-native-sketch模块和组件根本不起作用
EN

Stack Overflow用户
提问于 2017-08-23 05:20:40
回答 1查看 250关注 0票数 2
代码语言:javascript
复制
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条与以下错误消息类似的错误消息,该消息与下面的'In file included in file included from /Users/waltershub/Desktop/paintChalledgeNative/node_modules/react-native-sketch/RNSketch/RNSketch.m:11:../react-native/React/Base/RCTEventDispatcher.h:18:3: error: redefinition of enumerator 'RCTTextEventTypeChange’RCTTextEventTypeChange,‘

EN

回答 1

Stack Overflow用户

发布于 2017-08-29 11:41:19

我认为这是因为您使用了react-native-sketch0.5版本,该版本与React Native > 0.40不兼容。从那时起,一个新的1.0版本的has been published,所以也许你可以再试一次这个?(免责声明:我是react-native-sketch的维护者)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45827150

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档