H
H
humanIvan2018-11-07 12:36:06
React
humanIvan, 2018-11-07 12:36:06

How to conditionally display content in a functional component using the “?” operator?

export const ItemCheckbox = ({
  position,
}) => (
  {positin ? (
    <p>Hello</p>
  ) : (
    <p>Good</p>
  )}
)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-11-07
@humanIvan

Extra curly braces, should be like this:

const ItemCheckbox = ({
  position,
}) => (
  position ? (
    <p>Hello</p>
  ) : (
    <p>Good</p>
  )
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question