-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Description
- replace the result of
pip list | grep dash
below
dash 2.5.0
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table 5.0.0
Describe the bug
I cannot extract meta of react functional-component, while class component works well.
const ExternalShortcut: React.FC<Props> = () => {
return <div>example</div>
}; // It doesn't work..
//...
class ExternalShortcut extends React.Component<Props, any> {
render() {
return <div>example</div>;
}
} // It works!
dash/extract-meta.js
throws the error.
if (commentSource.valueDeclaration) {
^
TypeError: Cannot read properties of undefined (reading 'valueDeclaration')
at /Users/devsisters/Development/dashapp-poc-dashboard/src/components/lnb/venv/lib/python3.9/site-packages/dash/extract-meta.js:694:31
at Array.forEach (<anonymous>)
at /Users/devsisters/Development/dashapp-poc-dashboard/src/components/lnb/venv/lib/python3.9/site-packages/dash/extract-meta.js:645:17
at Array.forEach (<anonymous>)
at gatherComponents (/Users/devsisters/Development/dashapp-poc-dashboard/src/components/lnb/venv/lib/python3.9/site-packages/dash/extract-meta.js:640:33)
at Object.<anonymous> (/Users/devsisters/Development/dashapp-poc-dashboard/src/components/lnb/venv/lib/python3.9/site-packages/dash/extract-meta.js:754:18)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
This is how I fixed.
// Function components.
rootExp = typeSymbol;
// rootExp.valueDeclaration = rootExp.declarations[0]; // This line is what I add. This line makes the build of functional component success.
commentSource = rootExp.valueDeclaration;
if (
rootExp.valueDeclaration &&
rootExp.valueDeclaration.parent
) {
// Function with export later like `const MyComponent = (props) => <></>;`
commentSource = getParent(
rootExp.valueDeclaration.parent
);
}
Expected behavior
I expected to extract-meta.js
work well for react functional-component.
siner308
Metadata
Metadata
Assignees
Labels
No labels