Skip to content
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

How to use Recharts-to-png in class component react #445

Closed
karthikn1050 opened this issue May 31, 2022 · 3 comments
Closed

How to use Recharts-to-png in class component react #445

karthikn1050 opened this issue May 31, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@karthikn1050
Copy link

I am developed the project fully in class component. i want to create option to download the chart that i created with recharts but in the recharts documentation the example is only available for functional. i really need this for my class component kindly guide me how to use it on class component

@brammitch brammitch added the enhancement New feature or request label Jun 2, 2022
@brammitch
Copy link
Owner

The documentation is only for functional components because this library exports a hook, which will not work with class components.

Here's an example of how you could implement the download capability on your own with a class component:
https://codesandbox.io/s/recharts-download-class-component-sktfx9?file=/src/App.tsx

@brammitch brammitch self-assigned this Jun 2, 2022
@brammitch
Copy link
Owner

I'll work on getting a component added to this library that will let you use Render Props in a class component, instead of the hook.

@brammitch
Copy link
Owner

@karthikn1050 I have a version with a class component, using render props. Can you install version 2.2.0-rc.0 and test it out?

npm i recharts-to-png@2.2.0-rc.0

You can see the code and demo in #454 -- Let me know your thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants