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

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

export default Home

the error comes

src\components\Home.js Line 6:10: 'Container' is not defined react/jsx-no-undef
Antonio Laguna
  • 8,973
  • 7
  • 36
  • 72
  • Welcome to SO. You might find reading the site [help section](https://stackoverflow.com/help) useful when it comes to [asking a good question](https://stackoverflow.com/help/how-to-ask), and this [question checklist](https://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist). – Andy Oct 20 '21 at 05:24
  • 1
    The error is correct. `Container` isn't defined. – Andy Oct 20 '21 at 05:25
  • how to slove it – Pamod Akalanka Oct 20 '21 at 05:26
  • Have you created a `Container` component? If you have import it into `Home`. – Andy Oct 20 '21 at 05:27
  • plz tell me what that command to import Container – Pamod Akalanka Oct 20 '21 at 05:29
  • I can't. I don't know if you've created one, and I don't know what your folder structure looks like if you have. Maybe [start with this](https://reactjs.org/docs/getting-started.html). – Andy Oct 20 '21 at 05:35

1 Answers1

1

You need to define Container first for example:

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

If you have a Container that you are already created and exported defaultl then import it as follows

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

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

export default Home

If you export Container as constant then you need to import as

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

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

export default Home

For more please refer this

Rahman Haroon
  • 1,088
  • 2
  • 12
  • 36