question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'style' of null

See original GitHub issue

I’m using vue cli 3 to generate the project.

Then my component:

<template>
  <div id="rete" class="node-editor"></div>
</template>

<script>
import Rete from 'rete';
// import ConnectionPlugin from 'rete-connection-plugin';
import VueRenderPlugin from 'rete-vue-render-plugin';

import CustomNodeComponent from './CustomNodeComponent.vue';
import CustomControlComponent from './CustomControlComponent.vue';

const container = document.querySelector('#rete');
const editor = new Rete.NodeEditor('demo@0.1.0', container);
editor.use(VueRenderPlugin);

class MyComponent extends Rete.Component {
  constructor() {
    super();
    this.data.render = 'vue';
    this.data.component = CustomNodeComponent;
    this.data.props = {};
  }
}

class MyControl extends Rete.Control {
  constructor() {
    super();
    this.data.render = 'vue';
    this.data.component = CustomControlComponent;
    this.data.props = {};
  }
}

const myComponent = new MyComponent();
editor.register(myComponent);
const myControl = new MyControl();
editor.register(myControl);

export default {
  name: 'Flow',
  mounted() {
  },
};
</script>

<style scoped lang="scss">
</style>

On launch, I’m not getting anything rendered, and get

image

The error appear to be at line 15 of my code

L15         -> const editor = new Rete.NodeEditor('demo@0.1.0', container);
rete.esm.js -> _this.view = new EditorView(container, _this.components, _assertThisInitialized(_this));
rete.esm.js -> _this.container.style.overflow = 'hidden';

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
iKlsRcommented, Feb 25, 2019

@Ni55aN I was going to suggest the refs method but I’m still reading up on it. Also it’s a bit hard for a newbie like me to grok the layout of the examples in the retejs repo since these are done dynamically. Could you make a simple barebones example based on a new vue cli project with the best practices? The threejs example on codesandbox is also a bit heavy I fear.

1reaction
Ni55aNcommented, Feb 25, 2019

obviously, since you have no nodes

Test (dont forget async mounted())

    editor.addNode(await myComponent.createNode({}));
Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript TypeError: Cannot read property 'style' of null
The possible reason behind the error is that the JavaScript runs much earlier than the objects it requires from the webpage are loaded....
Read more >
How To Fix Cannot Read Property 'style' of Null in JavaScript
This error boils down to one problem. The element you are trying to access does not exist in the DOM (document object model)...
Read more >
Cannot read property 'style' of Null in JavaScript
To resolve the "Cannot read property 'style' of null" error, make sure that the DOM element you're accessing the style property on exists....
Read more >
JavaScript TypeError Cannot Read Property 'style' of Null
JavaScript TypeError Cannot Read Property 'style' of Null ... A typeerror is thrown when a value is not of the expected type. Unlike...
Read more >
how to fix this error Cannot read property of null ...
how to fix this error Cannot read property of null (reading 'style') ... Hi Andrew,. he's just saying that boxElement is null. That...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found