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

transformResponse() cannot return reactive() object in development #787

Open
matthew-white opened this issue May 9, 2023 · 0 comments
Open
Labels
requestData Changes to requestData resources

Comments

@matthew-white
Copy link
Member

When it receives a response from Backend, a requestData resource by default simply stores the response data. However, the resource can first transform the data by specifying a transformResponse() function. transformResponse() can be used to make the data fully or partly reactive. By default, the data is not reactive.

All that works well in production. However, we use Pinia in limited ways in development, and things don't always end up working. If transformResponse() returns a nonreactive object, then the Pinia store will store that. If transformResponse() returns a shallowReactive() object, then Pinia will correctly store that. However, if transformResponse() returns a fully reactive() object, then getting the data from the store returns a nonreactive object (!).

I'm not quite sure why that is. I suspect it has something to do with the fact that the initial state passed to the Pinia store is shallowReactive(), not reactive(). Just a guess, but it's possible that Pinia doesn't offer a lot of support for shallowReactive() objects.

Again, everything works as expected in production (without Pinia). This hasn't come up before in development because most data isn't reactive, and the data that is is usually shallowReactive(). However, I'm now making the entity resource fully reactive and have been running into issues. For now, I'll turn off Pinia in development, matching what happens in production.

@matthew-white matthew-white added the requestData Changes to requestData resources label May 9, 2023
matthew-white added a commit that referenced this issue May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
requestData Changes to requestData resources
Projects
None yet
Development

No branches or pull requests

1 participant