# NodeView constructor being called multiple times

**URL:** https://discuss.prosemirror.net/t/nodeview-constructor-being-called-multiple-times/2145
**Category:** Uncategorized
**Created:** [August 16, 2019, 2:54am UTC](https://discuss.prosemirror.net/t/nodeview-constructor-being-called-multiple-times/2145 "2019-08-16T02:54:17Z")
**Posts on this page:** 1
**Showing post:** 11

<div class="post-metadata">

### Author: ![bhl](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/bhl/32/4074_2.png) [@bhl](https://discuss.prosemirror.net/u/bhl)
#### Post date: [November 2, 2019, 6:24am UTC](https://discuss.prosemirror.net/t/nodeview-constructor-being-called-multiple-times/2145/11 "2019-11-02T06:24:50Z")

</div>

Any update on this issue?

I’m noticing the same behavior mentioned above: my custom inline nodeview is being re-created each time when there’s no characters before or after the nodeview, and a new character is inserted either before or after the nodeview.

 ![math](https://discuss.prosemirror.net/uploads/secondsite/original/2X/b/b9a03231b59fbad9c5a672a18f3cfe56dab536cd.gif)

The recreation of the nodeview is only an issue right after it is inserted, when the x^2 is deleted. However, I think this has to do more with how I’m using inputRules to initially insert the node.

```
new InputRule(/(?:\$)([^\$]+)(?:\$)$/, (state, match, start, end) => {
    const attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs
    const [matchedText, content] = match;
    const {tr} = state;
    if (matchedText) {
        // Create new Math node with content.
        const node = type.create(attrs, schema.text(content));
        tr.replaceWith(start, end, node);
        const cpos = tr.doc.resolve(tr.selection.anchor - tr.selection.$anchor.nodeBefore.nodeSize);
        tr.setSelection(new NodeSelection(cpos));
    }
    return tr
})

```

I’m guessing it’s because when I replace the selection with a new node, the text content within the node is not being synchronized with the editor.

A temporary solution, which I got from [Inline Nodes With Content](https://discuss.prosemirror.net/t/discussion-inline-nodes-with-content/496/3), is to add a space before and after the nodeview. This stops the nodeview from being re-created.

**Edit** Solution was, as marijn said, to update prosemirror-view. I had only updated prosemirror-view for my dependencies and not the main libraries themselves. 🙂

---

_[View the full topic](https://discuss.prosemirror.net/t/nodeview-constructor-being-called-multiple-times/2145)._
