Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
10
rated 0 times [  17] [ 7]  / answers: 1 / hits: 6936  / 4 Years ago, mon, february 3, 2020, 12:00:00

I am using useContext react hook.



Age.js



import React, { useContext } from 'react' ;
import Detail from '../context/detail';

const age = props =>{
const detail = useContext(Detail);
return(
<p>
Your age is : {detail.age}
</p>
);
}

export default age ;


It gives an error like this :
React Hook useContext is called in function age which is neither a React function component or a custom React Hook function


More From » reactjs

 Answers
0

Function components should start with uppercase , rename age to Age, to get rid of the error


[#4858] Friday, January 31, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
grayson

Total Points: 36
Total Questions: 113
Total Answers: 95

Location: Tonga
Member since Fri, Aug 21, 2020
4 Years ago
grayson questions
Mon, Sep 14, 20, 00:00, 4 Years ago
Fri, Feb 22, 19, 00:00, 5 Years ago
Sat, Feb 9, 19, 00:00, 5 Years ago
;