@Davidaa_WoW

Почему возникает Minified React error #321?

Пытаюсь познакомиться с хуком состояние useState, но у меня постоянно вылезает ошибка.
Ниже код. Что я делаю не так?
import React, { Component, useState } from 'react'
import { Text, View, StyleSheet, TextInput } from 'react-native'

class BetterInput extends Component {
	
	render() {
		const { placeholder, type, restrictions, inputText } = this.props
		const [key, setKey] = useState(0);
		return (
			<View style={styles.wrapper}>
				<TextInput
				style={styles.input}
				placeholder={placeholder}
				onChangeText={()=>setKey(key+1)}
				></TextInput>
				<Text
				>{key}</Text>
			</View>
		)
	}
}

const styles = StyleSheet.create({
	wrapper: {
		display: 'flex',
		alignItems: 'center',
		justifyContent: 'center',
	},
	input: {
		borderColor: 'gray',
		borderWidth: 1,
		height: 45,
		width: 345,
		borderRadius: 10,
	}
})

export default BetterInput
  • Вопрос задан
  • 784 просмотра
Решения вопроса 1
Simkav
@Simkav
Я так подозреваю что это из-за того что вы юзаете хуки в классах
doc
You can’t use Hooks inside a class component, but you can definitely mix classes and function components with Hooks in a single tree.
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

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

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