我正在尝试将emotion.js 与create-react-app 和TypeScript 一起使用。按照我在文件顶部添加@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 脚本)将不胜感激。