I am with this mistake, altough I do not how solve.
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:
You might have mismatching versions of React and the renderer (such as React DOM)
You might be breaking the Rules of Hooks
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
The mistake occurs when is call the file Iten.js
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(
setChecked(!checked)} checked={checked} />
{`⬅️ Click!`}
`
{nome}
</View>``
);`
}
I am trying execute this file Itens.js, which add a list with checkboxLabel, Image and Text, although I am getting the mistake “Error: Invalid hook call. Hooks can only be called inside of the body of a function component.”
I need to help. I don’t know what to do.
vinicius gabriel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.