3
respostas

Render Error: Invalid hook call

Olá, pessoal

Estou com esse erro, mas não sei como resolver.

Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem

O erro ocorre quando chama o file Iten.js, que anexei aqui.

import React, { useState } from "react"; import { Image, View, StyleSheet, TouchableOpacity } from "react-native"; import Texto from "../../../Components/Texto"; import CheckBox from 'expo-checkbox'; import { Ionicons } from '@expo/vector-icons';

function MyCheckbox({ onChange, checked }) { return ( <Pressable style={[styles.checkboxBase, checked && styles.checkboxChecked]} onPress={onChange}> {checked && } ); }

export default function Itens({ item: { nome, imagem } }) { const [Checked, setChecked] = useState (false);

return( 
    <View style={estilos.item}>
   
   <View style={styles.checkboxContainer}>
    <MyCheckbox onChange={() => setChecked(!checked)} checked={checked} />
    <Text style={styles.checkboxLabel}>{`⬅️ Click!`}</Text>
   </View>
    <Image source={imagem} style={estilos.imagem} />
    <Texto style={estilos.nome}>{nome}</Texto>

</View>
);

}

const estilos = StyleSheet.create({ checkB:{ alignSelf: "center", margin: 8, }, checkboxContainer: { flexDirection: 'row', alignItems: 'center', }, item: { flexDirection: "row", borderBottomWidth: 1, borderBottomColor: "#ECECEC", paddingVertical: 16, marginHorizontal: 16, alignItems: "center", }, imagem: { width: 46, height: 46, }, nome: { fontSize: 16, lineHeight: 26, marginLeft: 11, color: "#464646", }, checBo:{ width: 25, height: 25, borderWidth: 2, borderColor: 'green', marginRight: 5, }

})

3 respostas

de qual curso é isso?

Curso React, pessoal alguém pode me ajudar ?

linka aqui o curso pra entender teu contexto