enzymejs / enzymejs/enzyme

Question: failed to read attribute 'tabIndex' when setAttribute in useEffect

Open
#2,154 9 comments 0 reactions 0 assignees View on GitHub
Need More Information
Dominant language
JavaScript
Stars
19.8k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

```js
const inputRef = useRef(null);
useEffect(() => {
if (tabIndex){ // if tabIndex provided
inputRef.current.setAttribute('tabindex', tabIndex);
}
}, []);

return


```

test
```js
const wrapper = mount();
console.log(wrapper.update().find('input').props())
expect(wrapper.update().find('input').props()['tabindex']).toEqual(10); // undefined
// => {
// disabled: false
// }
// no tabIndex nor tabindex
```
Both of
```wrapper.update().find('input').props()['tabindex']```
and
```wrapper.update().find('input').props()['tabIndex']``` are ```undefined```

Anything wrong here?

#### API

- [ ] shallow
- [x] mount
- [ ] render

#### Version

| library | version
| ------------------- | -------
| enzyme | 3.10.0
| react | 16.8.6
| react-dom | 16.8.6
| react-test-renderer |
| adapter (below) | 1.14.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.