How To Pass An Array As Props In React Without Being Converted To String
I'm developing a university administration website with React that can be displayed in different languages. So far, I have developed the Login page, please see the code (note that
Solution 1:
As we can see LoginForm
expects 2 props, repos
and selectedLanguage
function LoginForm ({ repos, selectedLanguage }) { ... }
But you are passing only repos
,
<LoginForm repos={repos, selectedLanguage} />
Here selectedLanguage
is getting bind to repos
props and you are getting EU
in your console, whereas selectedLanguage
prop is not being passed and you got undefined
.
I am also surprised, why repos={repos, selectedLanguage}
is not giving syntax error
You need to separately pass both the values,
<LoginForm repos={repos} selectedLanguage={selectedLanguage} />
Post a Comment for "How To Pass An Array As Props In React Without Being Converted To String"