Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Support option to disable render optimization in useSnapshot #846

Closed
98mux opened this issue Jan 24, 2024 · 1 comment
Closed

Support option to disable render optimization in useSnapshot #846

98mux opened this issue Jan 24, 2024 · 1 comment

Comments

@98mux
Copy link

98mux commented Jan 24, 2024

I have an app where the image can update without the image_url updating, this caused an issue with useSnapshot and it would not register a change as image_url was identical to the previous one. So setting image_url would not update the image

A solution for this could be to add an option to useSnapshot, like this: useSnapshot(state, {disableOptimization:true});

Currently the solution I'm using is this:

const image_url = state.image_url:
state.image_url = undefined;
setTimeout(() => {state.image_url = image_url}, 10);

thought it is very ugly and causes 10ms of "flashing"

Maybe there is another way to solve this better?

@dai-shi
Copy link
Member

dai-shi commented Jan 24, 2024

Thanks for your feedback.
It's still vague, but I will probably consider changing the useSnapshot behavior in v3 and such options can be considerable. (but, as v2 isn't released yet, it's too early to consider.)

For now, I'd suggest to try use-valtio as an escape hatch.

@pmndrs pmndrs locked and limited conversation to collaborators Jan 24, 2024
@dai-shi dai-shi converted this issue into discussion #847 Jan 24, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants