I am trying to extend some of the components in React with some functionality. I have installed dash core components though NPM and the code builds.
TGraph.react.js
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import Graph from 'dash-core-components';
/**
*/
export default class TGraph extends Component {
render() {
const {id} = this.props;
return(
<Graph id={id}></Graph>
);
}
};
TGraph.defaultProps = {};
TGraph.propTypes = {
id: PropTypes.string
};
This all builds but then when I want to use this in the following file:
import new_components
import dash
from dash import html
external_scripts = [
'https://cdn.plot.ly/plotly-latest.min.js'
]
app = dash.Dash(__name__,
external_scripts=external_scripts)
app.layout = html.Div(
[
new_components.TGraph(id="graph")
]
)
if __name__ == "__main__":
app.run_server(debug=True)
The dash debugger gives me the following error:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it’s defined in, or you might have mixed up default and named imports.
Check the render method of
i
.
I have tried importing the Graph with import {Graph} from 'dash-core-components';
or with an alias as import {Graph as DCCGraph} from 'dash-core-components';
as in this question, but that didn’t help. I can’t find what it is trying to render with “i”.
Can anyone help?