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

[RED-18] Export buildHooks function #3450

Closed
lucashm opened this issue May 16, 2023 · 2 comments
Closed

[RED-18] Export buildHooks function #3450

lucashm opened this issue May 16, 2023 · 2 comments
Labels
enhancement New feature or request RTK-Query
Milestone

Comments

@lucashm
Copy link

lucashm commented May 16, 2023

I have a specific use case, where I'm using redux-toolkit through module federation, so all my micro-frontends can access it. The problem is that every micro-frontend has its own React instance, and the exported hooks from the ReactModule won't work as we can't call one Hook from different React versions.

My current solution is basically copying and pasting the code from the buildQueryHooks and buildMutationHooks functions, but it would make everything way cleaner if the function buildHooks were available!

Thanks for reading

Edit: Already created a PR since it's a really small change: #3451

RED-18

@phryneas
Copy link
Member

But you don't have half of the arguments for buildHooks available outside of the api.

Especially context is internal, and as we treat this api as internal, we will add any number of new arguments at any moment in time. Exporting the function would prevent us from doing that, and every new required argument we added would be a breaking change and need a new major release.

I'm sorry, but we cannot do that.

@lucashm
Copy link
Author

lucashm commented May 17, 2023

Hey @phryneas , thanks for the reply
I realized that once I actually tried to use it, sorry about it!

I updated my PR with some major changes. It seems that I also need to pass the specific React instance along with the redux functions from that instance as well. If no instance is set, then the default from peer dependency will be used.

I'm really not sure if there's a better way of handling this. Maybe this isn't even something scoped for the library, but since it solved my case, maybe it can help others as well.

Let me know what you think and please feel free to ask for any changes if this is relevant

@markerikson markerikson added this to the 2.0 milestone Aug 16, 2023
@markerikson markerikson added the linear Created by Linear-GitHub Sync label Sep 22, 2023
@markerikson markerikson changed the title Export buildHooks function [RED-18] Export buildHooks function Sep 22, 2023
@markerikson markerikson modified the milestones: 2.0, Post 2.0 Oct 1, 2023
@markerikson markerikson added enhancement New feature or request RTK-Query and removed linear Created by Linear-GitHub Sync labels Feb 6, 2024 — with Volta.net
@markerikson markerikson closed this as not planned Won't fix, can't repro, duplicate, stale Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request RTK-Query
Projects
None yet
Development

No branches or pull requests

3 participants