@antonpanamo

Как изменить текст в компоненте при клике на кнопку?

Как изменить эту переменную .что бы изменилось значение в компоненте?

this.textValue = g

import Checkbox from 'expo-checkbox';
import React, { useState } from 'react';
import { StyleSheet, Text, View, Alert, Modal,  Pressable, TextInput, Switch } from 'react-native';

export default function App() {
  
   const [number, onChangeNumber] = React.useState(null);
   const [counter1, setCounter1] = useState(0);
   
    var textValue = useState (' мой текст 123');
 
 this.handleClick = (g) => {
   this.textValue = g
    console.log('значение this:', g);
  }
   

  return (
  <>

    <Text>{textValue}</Text>

      <button onClick={() => this.handleClick('clickclick')}>
        Нажми на меня
      </button>
   
   </>


  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    marginHorizontal: 16,
    marginVertical: 32,
  },
  section: {
    flexDirection: 'row',
    alignItems: 'center',
  },
  paragraph: {
    fontSize: 15,
  },
  checkbox: {
    margin: 8,
  },
});
  • Вопрос задан
  • 557 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы