Home > Software engineering >  Passing integers to JSX attributes
Passing integers to JSX attributes

Time:02-08

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.

CodePudding user response:

Use curly brace:

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

It will pass integer.

Playground area

CodePudding user response:

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.

  •  Tags:  
  • Related