solidjs / solid-router

A universal router for Solid inspired by Ember and React Router
MIT License
1.14k stars 147 forks source link

useSubmission breaks when used with action.with() #491

Open KookiKodes opened 3 hours ago

KookiKodes commented 3 hours ago

Describe the bug

Let's say I have an action and the action needs properties to be associated with it no matter what. This can be done through the: with method associated with any given action. For some reason, if you have an action that is using the .with method and pass that into the useSubmission hook, it seems to force result of the useSubmission hook to always return undefined for every property. What's even weirder is if you have the following code:

const submission = useSubmission(withTestAction)
createEffect(() => {
  console.log(submission.pending)
})

The createEffect is aware of any submission to the action, but still returns undefined to whatever property you're listening to.

Your Example Website or App

https://stackblitz.com/edit/github-st5whm-swndrp?file=src%2Fcomponents%2FThemeToggle.tsx,src%2Froutes%2Findex.tsx

Steps to Reproduce the Bug or Issue

  1. Define an action.
  2. Use the .with() method to attach additional arguments to the action and associated the result to a new constant.
  3. Pass the action to the useSubmission hook.

Expected behavior

Whether an action is defined with or without using the with method, I would expect the useSubmission hook to still work.

Screenshots or Videos

Peek 2024-10-17 10-52

Platform

Additional context

This is just an assumption, but this seems to have a similar effect if you don't pass an action a name whenever you're defining one. Perhaps the .with() method somehow removes the name of the action?

KookiKodes commented 3 hours ago

Thanks ahead of time :) !