D
D
Denis Sokolov2022-02-15 15:38:23
React
Denis Sokolov, 2022-02-15 15:38:23

How to convert it to JSX?

size - this is what the tag should be (h1, h2, h3, h4, h5, h6)
How can I convert this code to JSX

export const Headline = ({ children, className, size }) => {
  return React.createElement(size, { className: classNames(s[size], className) }, children);
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2022-02-15
@Denis147258369

Replace size with something that starts with a capital letter, like this:

const Headline = ({ children, className, size: Tag }) => {
  return <Tag className={classNames(s[Tag], className)}>{children}</Tag>;
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question