Skip to content

Create useExternalFormApi hook #1596

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

matthewdavi
Copy link

This PR addresses an issue I raised here, #1595.

The new useExternalFormApi hook would make working with forms more ergonomic, as they are already external stores and there are many usecases for reading / writing to a store from outside of the react lifecycle.

@crutchcorn
Copy link
Member

This sounds like a terrible way to introduce memory leaks into your app. Can you provide programmatic usage for why we'd want to add this?

@matthewdavi
Copy link
Author

This sounds like a terrible way to introduce memory leaks into your app. Can you provide programmatic usage for why we'd want to add this?

Yes actually, i've been chatting on Discord with @LeCarbonator about this and I've created a sample repo. Can I add you to it?

@crutchcorn
Copy link
Member

Sure! I'm hesitant, because it sounds a bit like going against React best conventions, but happy to take a look at least.

@matthewdavi
Copy link
Author

Sure! I'm hesitant, because it sounds a bit like going against React best conventions, but happy to take a look at least.

I've added you. This seems fairly natural to me since it follows a similar headless pattern as Tanstack Store, and even Tanstack Query, which create their queryClients and stores at module level, which allows for much better ergonomics, being able to read / update values without being tied to the React lifecycle and passing props, or being within a specific context provider.

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.

2 participants