官术网_书友最值得收藏!

Boolean attributes

A couple more things are worth mentioning before starting for real regarding the way you define Boolean attributes in JSX. If you set an attribute without a value, JSX assumes that its value is true, following the same behavior of the HTML disabled attribute, for example.

This means that if we want to set an attribute to false, we have to declare it explicitly as false:

  <button disabled /> 
React.createElement("button", { disabled: true });

The following is another example:

  <button disabled={false} /> 
React.createElement("button", { disabled: false });

This can be confusing in the beginning, because we may think that omitting an attribute would mean false, but it is not like that. With React, we should always be explicit to avoid confusion.

主站蜘蛛池模板: 女性| 遂溪县| 治县。| 孟州市| 会宁县| 峨山| 五家渠市| 安化县| 二连浩特市| 漠河县| 中宁县| 江门市| 黑河市| 新田县| 商都县| 平江县| 屏边| 阿荣旗| 闸北区| 长葛市| 凭祥市| 临潭县| 梅河口市| 文安县| 镇平县| 疏附县| 阜新| 台南市| 团风县| 商水县| 郓城县| 兴安县| 寻乌县| 揭阳市| 达日县| 柯坪县| 左云县| 明星| 刚察县| 咸宁市| 娄烦县|