# React node view loses selection when switching between block types

**URL:** <https://discuss.prosemirror.net/t/react-node-view-loses-selection-when-switching-between-block-types/4691>\
**Category:** Uncategorized\
**Created:** [June 19, 2022, 1:34pm UTC](https://discuss.prosemirror.net/t/react-node-view-loses-selection-when-switching-between-block-types/4691 "2022-06-19T13:34:57Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![isaacaderogba](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/isaacaderogba/32/2895_2.png) [@isaacaderogba](https://discuss.prosemirror.net/u/isaacaderogba)\
**Post date:** [June 19, 2022, 4:23pm UTC](https://discuss.prosemirror.net/t/react-node-view-loses-selection-when-switching-between-block-types/4691/3 "2022-06-19T16:23:51Z")

</div>

No, I’m using React to render the paragraph.

```auto
const view = new EditorView(
      { mount: ref.current },
      {
        state,
        nodeViews: {
          paragraph(node) {
            return new ParagraphView(node);
          }
        }
      }
    );

```

The heading is using the `toDOM` setup from `prosemirror-schema-basic`. And yes, I can confirm that the node is being recreated, though I’m surprised that the selection is being lost when this happens. Changing the block type on the editor from the Prosemirror [homepage](https://prosemirror.net/) retains the selection, for example.

I’m also including an `ignoreMutation` method that returns false for selection events, to leave Prosemirror in charge of managing the selection.

```auto
ignoreMutation(mutation) {
        if (mutation.type === "selection") return false;
        return !this.contentDOM.contains(mutation.target);
      }

```

---

_[View the full topic](https://discuss.prosemirror.net/t/react-node-view-loses-selection-when-switching-between-block-types/4691)._
