Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Touchable child must either be native or forward setNativeProps to a native component at invariant #7

Open
L-Jovi opened this issue Feb 15, 2017 · 1 comment

Comments

@L-Jovi
Copy link

L-Jovi commented Feb 15, 2017

hi, my react-native version 0.37.0, and I use below object which provide to Stylesheet

styles

banner: {
  position: 'absolute',
  left: 0,
  right: 0,
  portrait: {
    top: 64 + 7,
  },
  landscape: {
    top: 0,
  },
}

js code

import React, { Component, } from 'react';
import {
  StyleSheet,
  View,
  Text,
  Image,
  TouchableOpacity,
  TouchableHighlight,
  TouchableWithoutFeedback,
} from 'react-native-responsive-styles';

class Banner extends Component {
  static styles = StyleSheet.create(styles);

  render() {
    const { styles, } = Banner;

    return () {
      <View style={styles.banner}>
        <TouchableWithoutFeedback
          onPress={actsMixed.platform.toggleDropDown}>
          <Animated.View style={[ styles.backDrop, { opacity: this.state.backdropOpacity, }, ]} />
        </TouchableWithoutFeedback>

        {/* some other components */}
      </View>
    }
    
  }
}

but I encounter the error as title say, how could I fix it?

image

thanks for your time.

regards.

@L-Jovi L-Jovi changed the title Invalid props.style key portrait supplied to View Touchable child must either be native or forward setNativeProps to a native component at invariant Feb 15, 2017
@jevakallio
Copy link
Contributor

It looks like we will need to provide a wrapper class for TouchableWithoutFeedback and TouchableHighlight which implements setNativeProps and forwards that to the child Touchable. See example here: https://facebook.github.io/react-native/docs/direct-manipulation.html#forward-setnativeprops-to-a-child

I'll gladly accept a PR with this change. Otherwise I can look at fixing this earliest next week.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants