DomParfitt / graphviz-react

React component for displaying Graphviz graphs
MIT License
101 stars 21 forks source link

Pass options in constructor to avoid useWorker warning #65

Closed 18chiatt closed 1 year ago

18chiatt commented 1 year ago

Currently, the argument options are being passed to graphviz after object construction via the .options method. This works fine, but during initialization graphviz may log a warning about useWorker even when the option { useWorker: false} is passed because the options are being passed in too late.

By merging this, we are allowing people to disable useWorker without having a noisy warning in their console. Related Issue #55

Right now this component throws the below error

import Graphviz from 'graphviz-react';

function WorkflowRenderer(props: Props) {
    const { title, workflow } = props;
    const classes = useStyles();
    const dotString = makeDotString(workflow);
    return (
        <>
            <div className={classes.taller}>
                <Heading>{title || 'Preview:'}</Heading>
                <Graphviz dot={dotString} options={{ useWorker: false }} />
            </div>
        </>
    );
}

Screen Shot 2022-08-31 at 9 46 20 AM