-1

All i need is to trigger onPress method of the ActionButton Without tapping on it.

Here is my code:

render () {
  // act = this.refs.abc;

  // alert(this.state.activeState)

  // this.handleAutoPress();
  return (
    // <View style={styles.container}>
   <View style={{flex:1, backgroundColor: '#f3f3f3'}} >
    <Text>Component10 Component</Text>

    {/*Rest of App come ABOVE the action button component!*/}
    <ActionButton ref="abc" buttonColor="rgba(231,76,60,1)"  >

      {/*<ActionButton.Item buttonColor='#9b59b6' title="New Task" onPress={() => 
        console.log("notes tapped!")}>
        <Icon name="android-create" style={styles.actionButtonIcon} />
      </ActionButton.Item>*/}
      <ActionButton.Item buttonColor='#3498db' title="Notifications" onPress={() => {}}>
        <Icon name="md-done-all" style={styles.actionButtonIcon} />
      </ActionButton.Item>
      <ActionButton.Item buttonColor='#1abc9c' title="All Tasks" onPress={() => {}}>
        <Icon name="md-done-all" style={styles.actionButtonIcon} />
      </ActionButton.Item>
    </ActionButton>
    </View>
    // </View>
  )
}
user5226582
  • 1,946
  • 1
  • 22
  • 37

1 Answers1

1

You probably want to follow the instructions in this answer: How can I trigger a tabItem onPress within a component using React Native?

Instead of trying to invoke the onPress itself, just set onPress prop to a function and invoke that function wherever needed. No need to mess with refs or anything like that.