function to overwrite global options don't update after dependency change
Describe the bug I'm using a API that needs to send a dynamic value on header. But when this value changes, the function that overwrite the global options use the old value.
⚠️ Make a Codesandbox ⚠️ https://codesandbox.io/s/usefetch-use-http-todo-list-app-managed-state-forked-b6i4w?file=/src/index.js
To Reproduce Steps to reproduce the behavior:
- Click on "Change dependency"
- See "dependency: 0" changing next to the button
- See console.log where the value don't change
Expected behavior The overwite global options function must use updated values.
Feel free to submit a PR.
@joaoarieira were you ever able to get around this issue, I'm also having the same problem, thanks
Facing the same issue
I think I resolved the issue
I modified the codesandbox https://codesandbox.io/s/usefetch-use-http-todo-list-app-managed-state-forked-q72vnx?file=/src/index.js.
Problem is the execution context of the options function and JavaScript variable reference I believe the options function executes only once. that is at the time of mount to derive/compute the options
Plese verify and let me know if it helps
@joaoarieira @ahmadcitrusbits @veloware
@krishnasaga hi,i can console new value by xxcurrent, but the value in post body is still old value, hope u can reply me thx!! this is a post demo https://codesandbox.io/s/usefetch-provider-forked-hk73gu?file=/src/index.js
@krishnasaga hi,i can console new value by xxcurrent, but the value in post body is still old value, hope u can reply me thx!! this is a post demo https://codesandbox.io/s/usefetch-provider-forked-hk73gu?file=/src/index.js
If it is about a different issue then you need to open a new thread