snippet
How to use condition on JSX
If you want make condition in your JSX, write this condition on braces. This exemple return a title of page from type. If titleName equal home, React return Homepage into H1, if title not equal return other title.
const el = <h1>{titleName === "home" ? "Homepage" : "Single page"}</h1>;
Related snippets |
---|