Replies: 1 comment
-
Have you considered just mixing one reducer into a hook instead? const useChangeAvatarPageModel = () => {
const dispatch = useDispatch()
return {
... dispatch.fileUploaderModel,
... dispatch.avatarModel,
}
}
const Foo: React.FC = () => {
const { uploadFile } = useChangeAvatarPageModel();
React.useEffect(() => {}, [
// The type of "apiResponse" should be "Promise<ApiResponse>", see the return type from the first code snippet.
const apiResponse = uploadFile();
]);
// ...
}; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi guys, first of all - thanks for creating such a great library that simplifies things a lot! I have had some experience working with Rematch though I haven't found a way to nest models or another proper way to implement any kind of inheritance. Let me give a quick example:
Suppose we have a piece of code that is capable of uploading a file to the API:
Now imagine we have a few other models that would like to reuse this logic, e.g.:
The question is, how do we reuse the code from the first code snippet to make the models from the second snippet have all these properties of the
FileUploaderModel
? What are the best practices? How to make sure that when I useuseDIspatch
the types are preserved?Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions