Skip to content
Advertisement

which is the correct way to acces the props? [closed]

I think I’m not accessing the property src correctly, this can be found in all the objects in a line like this one

logo: <img className=”Mediumsquare” src={imgrep(1)} alt=”altofem”

whenever I try to render them accessing the src, I get the error × typeerror cannot read property of undefined (reading ‘props’)

I have been stuck for a week since this error comes and go :(, thank you in advance!

JavaScript

Advertisement

Answer

Class Component

JavaScript

Functional Component

JavaScript

Rest, in your long lengthy code, you might find what goes wrong — I gave you basic-accessibility of props (or how to access them) in both types of components – Class & Functional.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement