import { Component } from "react";
import SvgTouchableMixin from "../lib/SvgTouchableMixin";
import _ from "lodash";

class Shape extends Component {
    constructor() {
        super(...arguments);
        _.forEach(SvgTouchableMixin, (method, key) => {
            this[key] = method.bind(this);
        });
        //noinspection JSUnusedGlobalSymbols
        this.state = this.touchableGetInitialState();
    }
}

export default Shape;

import { Component } from "react";
import SvgTouchableMixin from "../lib/SvgTouchableMixin";
import _ from "lodash";

class Shape extends Component {
    constructor() {
        super(...arguments);
        _.forEach(SvgTouchableMixin, (method, key) => {
            if (typeof method === 'function') {
                this[key] = method.bind(this);
            } else {
                this[key] = method;
            }
        });
        //noinspection JSUnusedGlobalSymbols
        this.state = this.touchableGetInitialState();
    }
}

export default Shape;

Fix compat with latest RN master
Fix compat with latest RN master

The code in the Shape constructor assumes that `SvgTouchableMixin` contains only functions but [this](https://github.com/facebook/react-native/blob/master/Libraries/Components/Touchable/Touchable.js#L904) was added which breaks this assumption.

This simply makes sure whatever we assign is a function before calling `.bind`.