• 06-08-2023, 00:24:17
    #1
    Merhaba hocalarım react yazmaya başladım, alttaki kodda ilettiğim hatayı alıyorum yardımcı olabilcek müsait bir hocam varmıdır?

    Benim Kodum:


    import { observer } from 'mobx-react-lite';
    import { ProductList } from '@/storefront';
    import { ProductSliderProps } from '../__generated__/types';
    import 'swiper/css';
    import { Swiper, SwiperSlide } from 'swiper/react';
    import styles from './style.module.css';
    const Right = ({ productList }: ProductListProps) => {
    return (
    <S.Main>
    <Header productList={productList} />
    <S.Products>
    <Swiper>
    {productList.data.map((product) => (
    <SwiperSlide key={product.selectedVariant.id}>
    <Product product={product} />
    </SwiperSlide>
    ))}
    </Swiper>
    </S.Products>
    <Pagination productList={productList} />
    </S.Main>
    );
    };
    export default Right;


    Aldığım Hata:


    Server Error

    ReferenceError: S is not defined
    This error happened while generating the page. Any console logs will be displayed in the terminal window.

    Source


    src/components/product-slider/index.tsx (11:4) @ Right
    9 | const Right = ({ productList }: ProductListProps) => {
    10 | return (
    > 11 | <S.Main>
    | ^
    12 | <Header productList={productList} />
    13 | <S.Products>
    14 | <Swiper>
  • 06-08-2023, 00:27:53
    #2
    En büyük yardımcınız burada hocam

    https://chat.openai.com/
  • 06-08-2023, 00:29:32
    #3
    adwerd0z1 adlı üyeden alıntı: mesajı görüntüle
    En büyük yardımcınız burada hocam

    https://chat.openai.com/
    Hocam 10 dakikadır muhabbet ettik olmadı google bard'a yazdım o da yapamadı en son çare buraya yazıyım dedim.
  • 06-08-2023, 00:34:23
    #4
    "ReferenceError: S is not defined"
    S tanımlanmamış. Kodunuzun en üstüne:
    const S = {
        Main: styled.div`
            /* Main */
        `,
        Products: styled.div`
            /* Products  */
        `,
    ekleyip dener misiniz?
  • 06-08-2023, 00:37:27
    #5
    GVertigang adlı üyeden alıntı: mesajı görüntüle
    "ReferenceError: S is not defined"
    S tanımlanmamış. Kodunuzun en üstüne:
    const S = {
        Main: styled.div`
            /* Main */
        `,
        Products: styled.div`
            /* Products  */
        `,
    ekleyip dener misiniz?
    "
    import { observer } from 'mobx-react-lite';
    import { ProductList } from '@/storefront';
    import { ProductSliderProps } from '../__generated__/types';
    import 'swiper/css';
    import { Swiper, SwiperSlide } from 'swiper/react';
    import styles from './style.module.css';
    const Right = ({ productList }: ProductListProps) => {
    return (
    const S = {
    <S.Main>
    <Header productList={productList} />
    <S.Products>
    <Swiper>
    {productList.data.map((product) => (
    <SwiperSlide key={product.selectedVariant.id}>
    <Product product={product} />
    </SwiperSlide>
    ))}
    </Swiper>
    </S.Products>
    <Pagination productList={productList} />
    </S.Main>
    }
    );
    };
    export default Right;"
    bu şekilde ekledim hocam fakat hala aynı ve eklediğim kısım içinde hata veriyor
  • 06-08-2023, 00:40:07
    #6
    styled-components kütüphanesini kullanmanız lazım. Ayrıca Main ve Products için stil de belirlememişsiniz. Lütfen kodun tamamını aşağıdaki gibi değiştirin. Çalışırsa gerekli kısımların CSS düzenlemesini yaparsınız. Örnek olması açısından doldurdum.

    import styled from 'styled-components';
    
    const S = {
        Main: styled.div`
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            background-color: #f5f5f5;
            padding: 20px;
        `,
        Products: styled.div`
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            grid-gap: 20px;
        `,
    };
    
    import { observer } from 'mobx-react-lite';
    import { ProductList } from '@/storefront';
    import { ProductSliderProps } from '../__generated__/types';
    import 'swiper/css';
    import { Swiper, SwiperSlide } from 'swiper/react';
    import styles from './style.module.css';
    
    const Right = ({ productList }: ProductListProps) => {
        return (
            <S.Main>
                <Header productList={productList} />
                <S.Products>
                    <Swiper>
                        {productList.data.map((product) => (
                            <SwiperSlide key={product.selectedVariant.id}>
                                <Product product={product} />
                            </SwiperSlide>
                        ))}
                    </Swiper>
                </S.Products>
                <Pagination productList={productList} />
            </S.Main>
        );
    };
    
    export default Right;
  • 06-08-2023, 00:40:10
    #7
    Mobilden baktımda “S” ile ilgili bir importunuz yok. Onu bir kontrol etmenizi tavsiye ederim.