Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

115
Visualizações
Props undefined when passed to component

Trying to pass dummy data to a component, props get passed as undefined and even console.log() inside the same page does not work? could someone please tell whats wrong here

import AllPosts from "../../components/posts/all-posts"

var DUMMY_POST = [
    {
        title: 'ter',
        slug:'getting-starterd',
        image:'getting-started-nextjs.png',
        excerpt: 'nkjadnknsdk,nsdikns',
        date: '2022-06-12'
    },
    {
        title: 'ter',
        slug:'getting-starterd-by',
        image:'nextjs-file-based-routing.png',
        excerpt: 'nkjadnknsdk,nsdikns',
        date: '2022-06-12'
    }
]
function AllPostsPage() {
    console.log(DUMMY_POST)
    return <AllPosts posts={DUMMY_POST}/>
}
export default AllPostsPage

_app.js file

import '../styles/globals.css'
import Layout from '../components/layout/layout'

function MyApp({ Component, pageProps }) {
  return (
    <Layout>
    <Component {...pageProps} />
    </Layout>
  )
}

export default MyApp

all-posts file

import classes from './all-posts.module.css'
import PostsGrid from './posts-grid'

function AllPosts(props) {
    // console.log(props)
    return (
    <section className={classes.posts}>
        <h1>All posts</h1>
        <PostsGrid posts={props.posts} />
    </section>
    )
}
export default AllPosts()

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I would declare DUMMY_POST inside the AllPostPage function first and give it a try.

about 4 years ago · Juan Pablo Isaza Relatório

0

import classes from './all-posts.module.css'
import PostsGrid from './posts-grid'

function AllPosts(props) {
    // console.log(props)
    return (
    <section className={classes.posts}>
        <h1>All posts</h1>
        <PostsGrid posts={props.posts} />
    </section>
    )
}
export default AllPosts;
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda