-
Notifications
You must be signed in to change notification settings - Fork 185
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
Using canvas-datagrid in React #548
Comments
Hi @romanstetsyk , my apologies for the late reply. We most definitely need to update the documentation, good point. I'll try to make some time for that later this week. It's not obvious from the documentation, but the reason why As for how to add event listeners, you'll need to set those imperatively. I've set up a short example here, using React hooks instead of class components (we're still in the process of upgrading to React hooks at work, so I might not have all the details right). The gist is using |
Let me know if you have any other questions, I've got some more time to respond now, and happy to help — would like to update docs to make use of modern React, so if you find anything lacking let me know. In the future, we'd like to offer a (type-safe) wrapper for React, but haven't had the time for that yet :-) |
Hi @ndrsn, thanks for your reply! This is something similar I came up with. However, I created a I also noticed that some events, like |
Is there any way to use |
How do you mean 'use' ? It's been a while since any part of that code's changed, but that file is listed in |
I think that makes sense — My
I'm not the original author, so I can't speak with full certainty, but it seems acceptable to me that rendering logic is triggered on mouse move (and thus events like |
Sorry, it wasn't a thoughtful question. I look into this package through the prism of React. I'm trying to create a reusable wrapper with all the supported attributes, properties, and events and was searching for easy ways to add types 😅. |
Even less thoughtful questions are welcome :) The types file is generated based on the JSDoc annotations, but I'm not sure how well we're actually checking the types. I'm going to upgrade the build system this week to get rid of webpack and rollup in favor of vite, and I'll see if I can do something about the types. A reusable wrapper for React would be most welcome! It's been on the roadmap for ages, but I felt better tests and types would have to come first. Luckily, I have some more time now to spend on that. |
That sounds like a fantastic idea! Should we expect a version update soon? Edit: just noticed it's already updated! |
Does anyone have a working example of using
canvas-datagrid
with React and TypeScript? There is a tutorial with an example that usesreact@15.5.4
, but I couldn't figure out how to convert it to modern syntax. Here is a codesandbox with my attempt. It doesn't work as expected: theallowSorting
option is not working, anddata
accepts a stringified array, not just an array. There's also no way to add event listeners with this implementation. I would appreciate it if someone gave me some pointers on how to use it correctly in React. ThanksThe text was updated successfully, but these errors were encountered: