In react native app, onclick function doesn't work


Sri Raman

I am a new local. I wrote the following code to call a function if the user clicks on the text.

var login = React.createClass({
     openPopup: function(){
        console.log("function called");
     },
     render: function(){
        return (
           <View onClick={this.openPopup}>
              <Text>
                 Login
              </Text>
           </View>
        );
     }
});

Is there anything wrong with the code above? If I click on the login text, I don't get any feedback in the console.

EDIT This question is react-native specific. Not a duplicate of any other question on stack overflow.

dangerous

Try this-

<TouchableOpacity onPress={this.openPopup}> 
    <View> <Text>...</Text> </View> 
</TouchableOpacity>

Related


In react native app, onclick function doesn't work

Sri Raman I am a new local. I wrote the following code to call a function if the user clicks on the text. var login = React.createClass({ openPopup: function(){ console.log("function called"); }, render: function(){ return (

In react native app, onclick function doesn't work

Sri Raman I am a new local. I wrote the following code to call a function if the user clicks on the text. var login = React.createClass({ openPopup: function(){ console.log("function called"); }, render: function(){ return (

In react native app, onclick function doesn't work

Sri Raman I am a new local. I wrote the following code to call a function if the user clicks on the text. var login = React.createClass({ openPopup: function(){ console.log("function called"); }, render: function(){ return (

In react native app, onclick function doesn't work

Sri Raman I am a new local. I wrote the following code to call a function if the user clicks on the text. var login = React.createClass({ openPopup: function(){ console.log("function called"); }, render: function(){ return (

In react native app, onclick function doesn't work

Sri Raman I am a new local. I wrote the following code to call a function if the user clicks on the text. var login = React.createClass({ openPopup: function(){ console.log("function called"); }, render: function(){ return (

onClick() doesn't trigger function in React-Native App

Alex In my react-native mobile app, I've written a component called Row in row.js that contains an TouchableOpacityevent onClick()handler. However, when the component is clicked, the function does not run. The Row component displays some text about a specific

.map function doesn't work with React Native

fwara07 I have a function .map()with JSX code . Although, JSX doesn't render. It only renders after I save the file. I am using expo (React Native). Here is my code: import React, { useEffect, useState } from "react"; import * as SecureStore from "expo-secure-

<a> onclick function doesn't work

btf217 My function is not firing after the code is clicked. Here is my code: HTML: <div data-role="footer"> <div data-role="tabstrip" id="tabs"> <a href="views/contacts.html" data-icon="home" id="home">Home</a> <a href="views/settings.ht

<a> onclick function doesn't work

btf217 My function is not firing after the code is clicked. Here is my code: HTML: <div data-role="footer"> <div data-role="tabstrip" id="tabs"> <a href="views/contacts.html" data-icon="home" id="home">Home</a> <a href="views/settings.ht

calling function from button onclick doesn't work react js

Cavaliers 2016 I am new to javascript and trying to figure this out. I'm trying to get the div structure in renderNewCard() to appear on the page every time the button is clicked. The button seems to work when I just call the function for the warning message,

calling function from button onclick doesn't work react js

Cavaliers 2016 I am new to javascript and trying to figure this out. I'm trying to get the div structure in renderNewCard() to appear on the page every time the button is clicked. The button seems to work when I just call the function for the warning message,

react-native-file-viewer doesn't work in my app

ED I try to use react-native-file-viewer in my app to view à pdf file. I have imported the lib like this:import FileViewer from 'react-native-file-viewer'; And I have à function: getPdf(){ const path = '../images/Charte.pdf'; FileViewer.open(pa

react-native-file-viewer doesn't work in my app

ED I try to use react-native-file-viewer in my app to view à pdf file. I have imported the lib like this:import FileViewer from 'react-native-file-viewer'; And I have à function: getPdf(){ const path = '../images/Charte.pdf'; FileViewer.open(pa

WebStorm-React-Native App Simulator doesn't work

RC_02 I created a brand new React-Native app using WebStorm. When I click Run -> iOS triggers in iOS Simulator, I don't see iOS Simulator load. I don't see any errors either. Here is the screenshot after running the project. Now I can run react-native run-iost

Routing doesn't work on load on my react native app

username I'm working on a React native project with a login system using Firebase. The login system works normally. I also managed to capture the current user id from Firebase. I tried setting "stay logged in" with the asyncStorage system and current user id.

react-native-file-viewer doesn't work in my app

ED I try to use react-native-file-viewer in my app to view à pdf file. I have imported the lib like this:import FileViewer from 'react-native-file-viewer'; And I have à function: getPdf(){ const path = '../images/Charte.pdf'; FileViewer.open(pa

WebStorm-React-Native App Simulator doesn't work

RC_02 I created a brand new React-Native app using WebStorm. When I click Run -> iOS triggers in iOS Simulator, I don't see iOS Simulator load. I don't see any errors either. Here is the screenshot after running the project. Now I can run react-native run-iost

WebStorm-React-Native App Simulator doesn't work

RC_02 I created a brand new React-Native app using WebStorm. When I click Run -> iOS triggers in iOS Simulator, I don't see iOS Simulator load. I don't see any errors either. Here is the screenshot after running the project. Now I can run react-native run-iost

react-native-file-viewer doesn't work in my app

ED I try to use react-native-file-viewer in my app to view à pdf file. I have imported the lib like this:import FileViewer from 'react-native-file-viewer'; And I have à function: getPdf(){ const path = '../images/Charte.pdf'; FileViewer.open(pa

Routing doesn't work on load on my react native app

username I'm working on a React native project with a login system using Firebase. The login system works normally. I also managed to capture the current user id from Firebase. I tried setting "stay logged in" with the asyncStorage system and current user id.

react native wait doesn't work in pressed function

hero 182448 I have an async function using redux that calls an API and returns a response from the server: function xyz() { return async (dispatch, getState) => { const { user: { token } } = getState(); return axios.get(API_URL, { headers: {

Why onpress function doesn't work in react native

Rushi dave class file export class salon extends Component { constructor(props) { super(props); this.state = { status : true, }; } _toggleModal(){ Alert.alert('hello'); } } I use the navigation option in the si

react native wait doesn't work in pressed function

hero 182448 I have an async function using redux that calls an API and returns a response from the server: function xyz() { return async (dispatch, getState) => { const { user: { token } } = getState(); return axios.get(API_URL, { headers: {

Why doesn't my debounce function work in a React app with hooks?

rookie My goal is to trigger a fetch request to fetch data from the API after some delay. In my particular case, I have an input field where the user can enter the post ID. I don't want to trigger a fetch request on every number entered in the input field. I o

Why doesn't my debounce function work in a React app with hooks?

rookie My goal is to trigger a fetch request to fetch data from the API after some delay. In my particular case, I have an input field where the user can enter the post ID. I don't want to trigger a fetch request on every number entered in the input field. I o

Why doesn't my debounce function work in a React app with hooks?

rookie My goal is to trigger a fetch request to fetch data from the API after some delay. In my particular case, I have an input field where the user can enter the post ID. I don't want to trigger a fetch request on every number entered in the input field. I o

Why doesn't my debounce function work in a React app with hooks?

rookie My goal is to trigger a fetch request to fetch data from the API after some delay. In my particular case, I have an input field where the user can enter the post ID. I don't want to trigger a fetch request on every number entered in the input field. I o

Why doesn't my debounce function work in a React app with hooks?

rookie My goal is to trigger a fetch request to fetch data from the API after some delay. In my particular case, I have an input field where the user can enter the post ID. I don't want to trigger a fetch request on every number entered in the input field. I o