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.

Rendering a polydata in a div + React

See original GitHub issue

Objective: to display a polydata in a div using React Method: in App.js, I have:

class App extends React.Component {
  constructor(props) {
    super(props);
    this.vtkRef = React.createRef();
  }

  componentDidMount() {
    const container = this.vtkRef.current;
    update(container);
  }

  render() {
    return <div ref={this.vtkRef} style={{width: 500, height: 500}}/>;
  }
}

The update(container) calls:

const update = (container) => {
        // bunch of stuff happening
        // ...
        const openglRenderWindow = vtkOpenGLRenderWindow.newInstance();
        renderWindow.addView(openglRenderWindow);
        
        openglRenderWindow.setContainer(container);
        const {width, height} = container.getBoundingClientRect();
        openglRenderWindow.setSize(width, height);

        const interactor = vtkRenderWindowInteractor.newInstance();
        interactor.setView(openglRenderWindow);
        interactor.bindEvents(container);
        interactor.initialize();
        interactor.setInteractorStyle(vtkInteractorStyleTrackballCamera.newInstance()); 
}

In addition, I followed the instruction in this thread to make sure the webpack.config.js is setup correctly. To be specific, I ran npm run eject, modified the webpack.config.js by following this instruction, remove the node modules directory followed by npm install and npm i worker-loader

Now I’m getting this error:

image

My guess is this has to do something with how I configured the webpack or passing the container as I tested the code without React and had no issues whatsoever.

Any comments is greatly appreciated.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
thewtexcommented, Jun 12, 2019

For future reference, this project can be helpful to add the required loaders in the required order for create-react-app:

https://github.com/thewtex/craco-vtk

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rendering Elements - React
Rendering an Element into the DOM​​ We call this a “root” DOM node because everything inside it will be managed by React DOM....
Read more >
VTK.js, React, JavaScript: Load VTK files - Stack Overflow
I am using a node server. In addition I have written the code as React code: import React from 'react'; ...
Read more >
Changing scalars to render via setActiveScalars - Web - VTK
Hello, I am attempting to change the scalars that are rendered in a vtk.js ... <div className="App"> <div id="renderBox"> {polydata && <div ......
Read more >
Using vtk.js with React - Kitware, Inc.
This is a quickstart tutorial for using vtk.js with React. ... import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
Read more >
Understanding How To Render Arrays in React | DigitalOcean
Rendering Adjacent Elements with React.fragment. Prior to React v16.2, you could wrap a block of components in a <div> element. This would lead ......
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