-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(react): Add useProfiler hook #2659
Conversation
@@ -36,9 +37,11 @@ | |||
"prettier-check": "^2.0.0", | |||
"react": "^16.0.0", | |||
"react-dom": "^16.0.0", | |||
"react-test-renderer": "^16.13.1", |
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.
Peer dependency for @testing-library/react-hooks
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.
✌️ Changelog and a small nit
Otherwise 🥇
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.
Hey @AbhiPrasad @HazAT, is calling |
Hey @mrlubos.
For other questions, we recommend opening an issue on Github or asking on our forums about these kind of questions. That way, other people can easily search and find the answer (ask once, answer for many 🚀) |
Got it, thank you so much @AbhiPrasad! |
FYI @AbhiPrasad, the reason I ended up here is because I couldn’t find a reference for React Hooks in the Sentry documentation, so I searched this repository 😬 |
Yes, that was on purpose, we wanted to do some more testing with it before we made it fully public in documentation. It's still fully functional though, hence why we left it out for people to consume if they wanted it enough. Docs coming soon though! |
Will that work for React Native? |
@skrywus We are working on it now, we'll let you know. |
Following up #2647
Motivation
It's important that we support all available React paradigms for
@sentry/react
, and as such, support adding Sentry AM through React hooksIn this PR, we add a new hook
useProfiler
that operates exactly like how thewithProfiler
HOC works earlier.How does it work?
Implementation
The profiler hook leverages the
useEffect
hook to push a new activity on component mount, and then pop the activity when the component has fully rendered. See the React Hooks API docs for more info howuseEffect
works.