import React from 'react';
import PropTypes from 'prop-types';
import { NativeModules, requireNativeComponent, View } from 'react-native';

const SketchManager = NativeModules.RNSketchManager || {};

export default class Sketch extends React.Component {
  static propTypes = {
    fillColor: PropTypes.string,
    imageType: PropTypes.oneOf(['jpg', 'png']),
    onChange: PropTypes.func,
    onClear: PropTypes.func,
    strokeColor: PropTypes.string,
    strokeThickness: PropTypes.number,
    style: View.propTypes.style,
  };

  static defaultProps = {
    fillColor: null,
    imageType: 'png',
    onChange: () => {},
    onClear: () => {},
    strokeColor: '#000000',
    strokeThickness: 1,
    style: null,
  };

  constructor(props) {
    super(props);

    // Sketch base style properties
    this.style = {
      flex: 1,
      backgroundColor: 'transparent',
    };
  }

  state = {
    imageData: null,
  };

  onChange = (event) => {
    const { imageData } = event.nativeEvent;

    this.setState({ imageData });
    this.props.onChange(imageData);
  };

  onClear = () => {
    this.setState({ imageData: null });
    this.props.onClear();
  };

  clear = () => SketchManager.clearDrawing();

  save = () => SketchManager.saveDrawing(this.state.imageData, this.props.imageType);

  render() {
    const { fillColor, strokeColor, strokeThickness, ...props } = this.props;

    return (
      <RNSketch
        {...props}
        fillColor={fillColor}
        onChange={this.onChange}
        onClear={this.onClear}
        strokeColor={strokeColor}
        strokeThickness={strokeThickness}
        style={[this.style, this.props.style]}
      />
    );
  }
}

const RNSketch = requireNativeComponent('RNSketch', Sketch);

@@ -64,16 +64,18 @@
 import %7B
+%0A 
  NativeM
@@ -81,16 +81,18 @@
 Modules,
+%0A 
  require
@@ -111,14 +111,33 @@
 ent,
+%0A 
  View
- 
+,%0A  ViewPropTypes%0A
 %7D fr
@@ -216,16 +216,109 @@
 %7C%7C %7B%7D;%0A%0A
+//Fallback when RN version is %3C 0.44%0Aconst viewPropTypes = ViewPropTypes %7C%7C View.propTypes;%0A%0A
 export d
@@ -611,22 +611,21 @@
  style: 
-View.p
+viewP
 ropTypes

Fix ViewPropTypes error in RN 0.49+