-
Notifications
You must be signed in to change notification settings - Fork 118
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
Version 5 #1057
base: main
Are you sure you want to change the base?
Version 5 #1057
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -30,44 +30,31 @@ interface Props { | |||
} | |||
|
|||
export const HotkeysProvider = ({ initiallyActiveScopes = ['*'], children }: Props) => { | |||
const [internalActiveScopes, setInternalActiveScopes] = useState( |
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.
Maybe we could have this state wrapped in a React Context to allow separating enableScope and disableScope, thus allowing us to avoid re-renders where we use them.
This is a very painful problem right now, we cannot call useHotkeysContext() without having re-renders because of enabledScopes changing and causing every component calling useHotkeysContext() to re-render, even if they don't care about this dependency and just want to enable/disable a scope.
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.
I would be glad to collaborate on this because we do an extensive usage of scopes at https://github.com/twentyhq/twenty and we have problems managing re-renders.
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.
I don't think I quite understand this issue. enableScope
and disableScope
are already decoupled.
enabledScopes
is a state, so changing the value will retrigger depend components. I understand that this causes re renders when calling enableScope
, but the only fix would be to have the enabledScopes
in another context, which, API wise, seems weird.
Maybe I am missing something?
@@ -1,3 +1,4 @@ | |||
import React from 'react' |
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.
It might be a bit better to do a namespace import:
import React from 'react' | |
import * as React from 'react' |
Source: https://twitter.com/dan_abramov/status/1308739731551858689
This can make the difference in the future (React v19 or v20).
What is the current roadmap for v5? Just curious 🙃
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 the heads up. I have very limited time & motivation to improve on version 5. I hope this will change in the next months, but no promises.
# Conflicts: # documentation/yarn.lock # src/validators.ts # tests/useHotkeys.test.tsx
No description provided.