【发布时间】:2019-05-29 02:42:42
【问题描述】:
我正在尝试将 Emotion.js 与 create-react-app 和 TypeScript 一起使用。
在documentation 之后,我添加了@emotion/core,使用了import {jsx, css} from '@emotion/core'; 并在我的文件顶部添加了/** @jsx jsx */。
但是当我运行应用程序时,会抛出以下错误:
ReferenceError: jsx is not defined
这是我的示例组件:
/** @jsx jsx */
import {jsx, css} from '@emotion/core';
import React from 'react';
import {NavigationBar} from "./NavigationBar";
export const Header: React.FunctionComponent<{}> = () => (
<div css={{
backgroundColor: 'hotpink',
'&:hover': {
color: 'lightgreen'
}
}}>
<NavigationBar/>
Test
</div>
);
错误被抛出的那一行是函数的定义:export const Header: React.FunctionComponent<{}> = () => (
任何帮助如何使它工作(除了弹出 create-react-app 脚本)将不胜感激。
【问题讨论】:
标签: reactjs typescript create-react-app emotion