Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140071

How to access nested JSON object in ReactJS State?

$
0
0

I have state:

{
studentId: 1,
studentName: "Student",
religion: {
  religionId: 1,
  religionName: "RELIGION"
 }
}

How to access religionName in react?

I have tried access my student state like this:

const {studentState} = useContext(StudentContext);

return (
 <div>
  {studentState.studentId}
  {studentState.studentName}
  {studentState.religion.religionName}
 </div>
);

Undifined result when using {studentState.religion.religionName}


Viewing all articles
Browse latest Browse all 140071

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>