Skip to content

Touchable not working #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
VinceBT opened this issue Nov 20, 2016 · 10 comments
Closed

Touchable not working #257

VinceBT opened this issue Nov 20, 2016 · 10 comments

Comments

@VinceBT
Copy link
Contributor

VinceBT commented Nov 20, 2016

Whenever I use TouchableOpacity or TouchableHighlight, I get this error in the console :

bundle.js:707 Warning: Unknown props `onStartShouldSetResponder`, `onResponderTerminationRequest`, `onResponderGrant`, `onResponderMove`, `onResponderRelease`, `onResponderTerminate` on <button> tag. Remove these props from the element.

The page display properly but the onPress event is not fired when I click.

Environment (include versions)

OS: Windows 10
Device:
Browser: Chrome
React Native for Web (version): 0.0.49
React (version): 15.4.0

@necolas
Copy link
Owner

necolas commented Nov 20, 2016

Any example code? How are you importing components? It looks like the ResponderEventPlugin hasn't been injected.

@VinceBT
Copy link
Contributor Author

VinceBT commented Nov 20, 2016

// @flow

import React, { Component } from 'react';
import {
  View,
  Text,
  TouchableOpacity,
} from 'react-native';

export default class Button extends Component {

  _handlePress: Function = () => {
    alert('clicked');
  }

  render() {
    return (
      <TouchableOpacity onPress={this._handlePress}>
        <Text>Click Me !</Text>
      </TouchableOpacity>
    );
  }

}

@necolas
Copy link
Owner

necolas commented Nov 20, 2016

I can't reproduce the issue on codepen - https://codepen.io/necolas/pen/aBpeMB?editors=0011 - or in the official examples.

@VinceBT
Copy link
Contributor Author

VinceBT commented Nov 20, 2016

I downloaded the react-native-web-starter example and tried to use TouchableOpacity and got the same error

@wcastand
Copy link

wcastand commented Nov 21, 2016

hi, i have the same problem, my config is:

  • OSX Sierra 10.12.1
  • Browser: Chrome v54.0.2840.98
  • react: 15.4.0
  • react-native: 0.37.0
  • react-native-web: 0.0.50
import React, { Component } from 'react'
import {
  AppRegistry,
  StyleSheet,
  View,
  Text,
  TouchableHighlight,
} from 'react-native'

import { observer } from 'mobx-react/native'

const styles = StyleSheet.create({
  home: {
    flex: 1,
    flexDirection: 'column',
    justifyContent: 'center',
    alignItems: 'center',
  }
});

class Home extends Component {
  render() {
    const { store } = this.props;

    return (
      <View style={styles.home}>
        <Text>Home {store.counter}</Text>
        <TouchableHighlight onPress={() => store.up()}>
          <Text>Up</Text>
        </TouchableHighlight>
        <TouchableHighlight onPress={() => store.down()}>
          <Text>Down</Text>
        </TouchableHighlight>
        <TouchableHighlight onPress={() => store.reset()}>
          <Text>Reset</Text>
        </TouchableHighlight>
      </View>
    )
  }
}

export default observer(Home)

@wcastand
Copy link

I resolved the issue by downgrading to 0.0.49.
i also needed to downgrade react and react-dom to 15.3.1

@brianneisler
Copy link

Same as @wcastand. Might be a result of the react 15.4.0 release. They moved a bunch of classes around that RNW directly depends upon.

The issue I'm encountering is that even if I peg react to 15.3.2, react-native-web declares this dependency

"react-dom": "^15.3.2",

which is satisfied by 15.4.0 and seems to be incompatible with react-native-web at the moment.

@necolas
Copy link
Owner

necolas commented Nov 21, 2016

Yeah this looks like a [email protected] issue (see #255). Was confusing because your reports state that you're using [email protected]

@zubko
Copy link

zubko commented Feb 2, 2017

Hi, can you check pls this fork of React Native for Web: Playground?
http://codepen.io/zubko/pen/OWvdXR
Seems that TouchableHighlight isn't working again.
I guess for some other reason, but I'm not sure if it worth making a new GH issue.
This time the error is "Uncaught TypeError: Cannot read property 'setNativeProps' of undefined."

@toannd92
Copy link

Hi, go to web index.js and replace ReactDOM.render.... by ReactNative.render(, document.getElementById('root'));

Repository owner locked and limited conversation to collaborators Apr 18, 2017
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

6 participants