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

[v6] Breaking Change: Full ConcurrentMode Support & Unified Event Handler Code #121

Closed
childrentime opened this issue Dec 9, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@childrentime
Copy link
Owner

childrentime commented Dec 9, 2024

  1. Ensure that each custom hook is concurrent-mode safe. This requires following certain principles, such as:
    • avoiding reading or writing refs during the render process.
  2. When using external state management libraries, useSyncExternalStore must be used. However, this usually doesn't concern us as we generally don't store setState.
  3. Given that stable event handler hooks would only have incorrect values when read within a child component's useLayoutEffect, I believe we can temporarily ignore this scenario and uniformly wrap translated event handlers with useEvent.
function Example(props) {
  const callback = useDynamicCallback(props.callback);
  return <Child callback={callback} />;
}

function Child({ callback }) {
  useLayoutEffect(() => {
    // Child effects are run before parent effects!
    // This means the callback ref has not yet been updated-
    // which means that it still points to the previous version,
    // with stale values and potentially different behavior.
    // This function call will probably cause problems!
    callback();
  }, []);
}

references:
facebook/react#16956 (comment)
facebook/react#18003 (comment)

@childrentime
Copy link
Owner Author

childrentime commented Dec 9, 2024

The first step should be creating a v6 branch and cherry-picking the relevant previous commits into it.

@childrentime childrentime self-assigned this Dec 9, 2024
@childrentime childrentime added enhancement New feature or request help wanted Extra attention is needed labels Dec 9, 2024
@childrentime childrentime pinned this issue Dec 9, 2024
@FleetAdmiralJakob
Copy link
Collaborator

Why not just make all hooks that are not compatible with concurrent mode yet compatible on top of the main branch and then releasing everything together as v6?

@childrentime
Copy link
Owner Author

It depends on the v5 version with any new features or modifications. I'm mainly still thinking about supporting concurrent mode, where else does our code need to be changed to support, and if there are not too many changes, there is no need to pull a v6 branch

@childrentime
Copy link
Owner Author

#125

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

No branches or pull requests

2 participants