src\components\Home.js 行 6:10:'Container' 未定义 react/jsx-no-undef

src\components\Home.js Line 6:10: 'Container' is not defined react/jsx-no-undef

import React from 'react'
import styled from "styled-components";

function Home() {
    return (
        <Container>
            home
        </Container>
    )
}

export default Home

错误来了

src\components\Home.js Line 6:10: 'Container' is not defined react/jsx-no-undef

需要先定义Container 例如:

import React from 'react'
import styled from "styled-components";

const Container = styled.Text`
 font-size: 42;
`;

function Home() {
    return (
        <Container>
            home
        </Container>
    )
}

export default Home

如果您已经创建并默认导出了 Container,则按如下方式导入它

import React from 'react'
import styled from "styled-components";
import Container from "file-path";

function Home() {
    return (
        <Container>
            home
        </Container>
    )
}

export default Home

如果将 Container 导出为常量,则需要导入为

import React from 'react'
import styled from "styled-components";
import { Container } from "file-path";

function Home() {
    return (
        <Container>
            home
        </Container>
    )
}

export default Home