mirror of
https://github.com/qlik-oss/nebula.js.git
synced 2026-05-28 01:00:28 -04:00
45 lines
748 B
JavaScript
45 lines
748 B
JavaScript
import React, {
|
|
useEffect,
|
|
useContext,
|
|
useRef,
|
|
// useState,
|
|
} from 'react';
|
|
|
|
import NebulaContext from '../contexts/NebulaContext';
|
|
|
|
export default function Chart({ id, onLoad }) {
|
|
const nebbie = useContext(NebulaContext);
|
|
const el = useRef();
|
|
useEffect(() => {
|
|
const n = nebbie.get(
|
|
{
|
|
id,
|
|
},
|
|
{
|
|
context: {
|
|
permissions: ['passive', 'interact', 'select', 'fetch'],
|
|
},
|
|
element: el.current,
|
|
}
|
|
);
|
|
n.then(viz => {
|
|
onLoad(viz, el.current);
|
|
});
|
|
return () => {
|
|
n.then(v => {
|
|
v.close();
|
|
// v.unmount();
|
|
});
|
|
};
|
|
}, [id]);
|
|
|
|
return (
|
|
<div
|
|
ref={el}
|
|
style={{
|
|
height: '100%',
|
|
}}
|
|
/>
|
|
);
|
|
}
|