New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make graph data generic #435
Make graph data generic #435
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR @nathanpovo. Please see just a few comments.
Thanks for your work in this PR with the generic types @nathanpovo! Just merged, and will publish in a moment. |
This change is causing a TypeScript bug (microsoft/TypeScript#53287) for me when compiling. It’s not this repo’s fault, but the issue was that I was previously solving this problem by augmenting the package’s types: declare module "react-force-graph-2d" {
interface NodeObject extends VertexAttributes {
id: string;
x?: number;
y?: number;
fx?: number;
fy?: number;
}
interface LinkObject extends EdgeAttributes {
source: NodeObject;
target: NodeObject;
}
} When importing a generic type from a package and augmenting it without supplying the parameters, TypeScript crashes completely. I don’t suspect too many users will be in my boat, but if they run into this issue hopefully they find this. The solution is just to migrate to the new generic types. |
Fixes #196
This pull request adds the functionality to automatically infer the data format passed to the
ForceGraph
component with the use of TypeScript generics so that allForceGraph
functions/properties will automatically know the node and link data format.