Passing integers to JSX attributes

97
February 14, 2022, at 01:30 AM
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.

Answer 1

Use curly brace:

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

It will pass integer.

Playground area

Answer 2

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.

READ ALSO
Is this Possible to give String data type as Number in JavaScript

Is this Possible to give String data type as Number in JavaScript

Can i give string data type as Number For example

99
Selectively color radio button background if certain option selected

Selectively color radio button background if certain option selected

I'm looking for advice on how to selectively style with CSS, HTML or Javascript my set of radio buttons to have different background colors depending on which choice is selectedfor example, I would like technology score to have a background color of yellow...

77
Double-notched corner in CSS

Double-notched corner in CSS

Is it possible to produce the following shape containing a number with CSS:

93
centering a div in a grid item

centering a div in a grid item

I've been trying to horizontally center a div on the screen of an IphoneThe div is a bit narrower than the phone screen

61