Uncaught Error: Invalid hook call.
来源:6-4 最受欢迎的CSS-in-JS方案 - Emotion的安装与使用

大艾尔
2021-03-25
UnAuthenticedApp.tsx:
import React, { useState } from ‘react’;
import Login from './login’
import Register from './register’
import { Card, Button } from 'antd’
import styled from ‘@emotion/styled’
export function UnAuthenticedApp() {
const [registered, setRegistered] = useState(false)
return (
{registered ? : }
<Button onClick={() => setRegistered(!registered)}>
切换到{registered ? ‘登录’ : ‘注册’}
)
}
const Container = styled.divdisplay: flex; flex-direction: column; align-items: center; min-height: 100vh;
看console.log报的错应该是@emotion/styled的问题
写回答
1回答
-
大艾尔
提问者
2021-03-25
结案了,竟然是 cnpm i @emotion/styled 的问题,改用 yarn add @emotion/styled 就没报错了
00
相似问题