Babel错误:JSX值应为表达式或带引号的JSX文本 [英] Babel error: JSX value should be either an expression or a quoted JSX text

查看:471
本文介绍了Babel错误:JSX值应为表达式或带引号的JSX文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试将我的JSX代码编译成JS时,Babel出现了一个错误.如果这是一个明显的问题,我是新来的人,我会对此道歉,我无法找到任何与之相关的东西.我试图在这段代码中使用道具,并将pageTitle道具传递给我的FieldContainer组件.但是,这给了我一个问题,那就是不允许代码编译为JS.我在搜索中发现应在{}之间传递prop值,但添加这些值无济于事.有任何想法吗?谢谢!

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!

推荐答案

在这里很难说出您要做什么,但正如错误所言,属性的值必须为表达式{foo}或带引号的文本"foo".

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".

在这种情况下

Child={<LoginForm />}

Child={LoginForm}

可能就是您想要的.

这篇关于Babel错误:JSX值应为表达式或带引号的JSX文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆