Babel error: JSX value should be either an expression or a quoted JSX text

半城伤御伤魂 提交于 2019-12-18 18:52:28

问题


I'm getting an error from Babel when trying to compile my JSX code into JS. I'm new to react so apologies if this is an obvious issue, I wasn't able to find anything about it that seemed related. I'm attempting to use props in this chunk of code, and pass a pageTitle prop to my FieldContainer component. This is giving me an issue, though, that isn't letting the code compile to JS. I discovered in my searching that prop values should be passed between {}, but adding these did not help. Any ideas? Thanks!


回答1:


It's hard to tell what you are trying to do here, but as the error says, the value of an attribute must be an expression {foo} or quoted text "foo".

In this case

Child={<LoginForm />}

or

Child={LoginForm}

is probably what you want.




回答2:


I got this error because I failed to quote a property inside of the JSX:

<span aria-hidden=true ...

should have been

<span aria-hidden="true" ...


来源:https://stackoverflow.com/questions/32591301/babel-error-jsx-value-should-be-either-an-expression-or-a-quoted-jsx-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!