4

I have a template like this:

const Template = ({ data }) => {
  const { id } = data.Page
  const postNode = data.Page

  return (
    <Layout>
       // conditional logic here
       // if {id} is 40 output <AdditionalContent />
    </Layout>
  )
}

I want to know if it is possible to check the id to see if it is 40, then output <AdditionalContent> component.

Rain Man
  • 1,163
  • 2
  • 16
  • 49

1 Answers1

6

You can define like this

const Template = ({ data }) => {
  const { id } = data.Page
  const postNode = data.Page

  return (
    <Layout>
      {id===40 && <AdditionalContent />}
    </Layout>
  )
}
akhtarvahid
  • 9,445
  • 2
  • 26
  • 29