0

When I render React elements, for example, a Button, then an equivalent HTML button element is created in the DOM.

But, when I query the DOM I'm still getting a wrapped element.

HTMLButtonElement {
      '__reactInternalInstance$gt1haeiqrhv': FiberNode {
        tag: 5,
        key: null,
        ...
}

Why don't I get the native element as if I rendered a normal div using JSDOM? Is there a way to get it?

0

1 Answer 1

1

I suppose you have to query for getDOMNode:

const button = wrapper.find('button').getDOMNode();
// const button = wrapper.getDOMNode(); // <---if wrapper is button element

It will give you the lying dom element in the component.

Sign up to request clarification or add additional context in comments.

1 Comment

You are referring here to Enzyme, which is another wrapper on top of React. Accessing getDOMNode will just give me the same React wrapper I was talking about.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.