Skip to content

Commit 5e437a1

Browse files
EdwardEdward Baggott
Edward
and
Edward Baggott
authored
Change tabIndex to match the types (string to number) (#3409)
Co-authored-by: Edward Baggott <[email protected]>
1 parent bf09ba8 commit 5e437a1

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

content/blog/2017-09-08-dom-attributes-in-react-16.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ In React 16, we are making a change. Now, any unknown attributes will end up in
2929
React has always provided a JavaScript-centric API to the DOM. Since React components often take both custom and DOM-related props, it makes sense for React to use the `camelCase` convention just like the DOM APIs:
3030

3131
```js
32-
<div tabIndex="-1" />
32+
<div tabIndex={-1} />
3333
```
3434

3535
This has not changed. However, the way we enforced it in the past forced us to maintain a whitelist of all valid React DOM attributes in the bundle:
@@ -55,10 +55,10 @@ With the new approach, both of these problems are solved. With React 16, you can
5555

5656
```js
5757
// Yes, please
58-
<div tabIndex="-1" />
58+
<div tabIndex={-1} />
5959

6060
// Warning: Invalid DOM property `tabindex`. Did you mean `tabIndex`?
61-
<div tabindex="-1" />
61+
<div tabindex={-1} />
6262
```
6363

6464
In other words, the way you use DOM components in React hasn't changed, but now you have some new capabilities.
@@ -120,7 +120,7 @@ Below is a detailed list of them.
120120
* **Known attributes with a different canonical React name:**
121121

122122
```js
123-
<div tabindex="-1" />
123+
<div tabindex={-1} />
124124
<div class="hi" />
125125
```
126126

content/docs/introducing-jsx.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function getGreeting(user) {
9292
You may use quotes to specify string literals as attributes:
9393

9494
```js
95-
const element = <div tabIndex="0"></div>;
95+
const element = <div tabIndex={0}></div>;
9696
```
9797

9898
You may also use curly braces to embed a JavaScript expression in an attribute:

content/docs/reference-dom-elements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ As of React 16, any standard [or custom](/blog/2017/09/08/dom-attributes-in-reac
130130
React has always provided a JavaScript-centric API to the DOM. Since React components often take both custom and DOM-related props, React uses the `camelCase` convention just like the DOM APIs:
131131

132132
```js
133-
<div tabIndex="-1" /> // Just like node.tabIndex DOM API
133+
<div tabIndex={-1} /> // Just like node.tabIndex DOM API
134134
<div className="Button" /> // Just like node.className DOM API
135135
<input readOnly={true} /> // Just like node.readOnly DOM API
136136
```

0 commit comments

Comments
 (0)