S
S
shobanof2021-09-30 22:44:11
React
shobanof, 2021-09-30 22:44:11

How to render the CircleTopik component only in the middle Card component?

function Card() {
  return (
    <div className={s.mainBlock}>
      <CircleTopik />
    </div>
  )
}

function App() {
  return (
    <div className={s.app}>
      <Card />
      <Card />
      <Card />
    </div>
  )
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-09-30
@shobanof

function Card(props) {
  return (
    <div>
      {props.children}
    </div>
  );
}

function App() {
  return (
    <div>
      <Card />
      <Card>
        <CircleTopik />
      </Card>
      <Card />
    </div>
  );
}

or
function Card({ showCircle }) {
  return (
    <div>
      {showCircle ? <CircleTopik /> : null}
    </div>
  );
}

function App() {
  return (
    <div>
      <Card />
      <Card showCircle={true} />
      <Card />
    </div>
  );
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question