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

useActionData receives data from wrong action #11022

Closed
1 task done
MoSattler opened this issue Nov 14, 2023 · 5 comments · Fixed by #11023
Closed
1 task done

useActionData receives data from wrong action #11022

MoSattler opened this issue Nov 14, 2023 · 5 comments · Fixed by #11023

Comments

@MoSattler
Copy link

MoSattler commented Nov 14, 2023

What version of Remix are you using?

2.2.0

Are all your remix dependencies & dev-dependencies using the same version?

  • Yes

Steps to Reproduce

Steps:

  1. Submit parent.tsx (and notice that it posts to the correct action handler)
  2. Go to /parent/child
  3. Submit parent.child.tsx and notice that parents.tsx also updates to data from parent.child.tsx

Expected Behavior

that the component in parent.tsx only gets data from the action defined in parent.tsx.

Actual Behavior

When submitting parent.child.tsx, the component in parent.tsx receives data from action in parent.child.tsx.

Screen.Recording.2023-11-14.at.12.28.56.mov
@brophdawg11
Copy link
Contributor

This is fixed by #11023 and will be available in the next release 👍

@brophdawg11 brophdawg11 removed their assignment Nov 14, 2023
@brophdawg11 brophdawg11 added the awaiting release This issue have been fixed and will be released soon label Nov 14, 2023
Copy link
Contributor

🤖 Hello there,

We just published version 6.19.0-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 6.19.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@brophdawg11 brophdawg11 removed the awaiting release This issue have been fixed and will be released soon label Nov 22, 2023
@nicolas-besnard
Copy link

nicolas-besnard commented Nov 24, 2023

This doesn't seem to be a bug, but rather a feature. Looking at the useActionData documentation ( https://remix.run/docs/en/main/hooks/use-action-data#useactiondata):

Returns the serialized data from the most recent route action or undefined if there isn't one.

I would say that what you are experiencing is the expected behaviour

@brophdawg11
Copy link
Contributor

@nicolas-besnard - "most recent route action" is referring to the current contextual route in context, not any route in the tree. Otherwise, useActionData<typeof action>(); would be completely unreliable since the action data could be from any acton function in the app - not the specific action you are typing it with (the one for that route).

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 a pull request may close this issue.

3 participants