Passing integers to JSX attributes

Viewed 85
return <textarea className="tox-input" rows=2 ></textarea>;

I want to pass rows=2 to this tag. However, this results in the following error.

Parsing error: JSX value should be either an expression or a quoted JSX text.

After a bit of research, I couldn't find a way to solve this. Please could someone tell me the proper way to do it in JSX?

Note: Using rows={2} doesn't give an error, but it only shows one row.

2 Answers

Use curly brace:

return <textarea className="tox-input" rows={2} ></textarea>;

It will pass integer.

Playground area

Using rows={2} is the right call. Look for any css rule that limits the max height of the textarea or a parent element that does this.

Related