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

Version 5 #1057

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

Version 5 #1057

wants to merge 11 commits into from

Conversation

JohannesKlauss
Copy link
Owner

No description provided.

@vercel
Copy link

vercel bot commented Jul 21, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-hotkeys-hook ❌ Failed (Inspect) Feb 9, 2024 10:59am

@@ -30,44 +30,31 @@ interface Props {
}

export const HotkeysProvider = ({ initiallyActiveScopes = ['*'], children }: Props) => {
const [internalActiveScopes, setInternalActiveScopes] = useState(

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.

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.

Copy link
Owner Author

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'
Copy link
Contributor

@kachkaev kachkaev Dec 7, 2023

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:

Suggested change
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 🙃

Copy link
Owner Author

@JohannesKlauss JohannesKlauss Jan 4, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants