Skip to content

Why am I not seeing updates in my destructured MobX property? #4535

Answered by codeBelt
teilarer asked this question in Q&A
Discussion options

You must be logged in to vote

It looks like this issue is related to React's rendering behavior. You're storing linkURL in the handleSetUrlWithDestructure function, where you destructure it from the store with const { linkURL } = store; at the top of your component. However, the component hasn't re-rendered to reflect any updates to that value.

In contrast, in your handleSetUrl function, you're accessing linkURL directly from the store with store.linkURL. This ensures you're getting the updated value directly from the store, rather than from the component's current state.

This behavior is similar to how useState and useRef work. With useState, you need to wait for the component to re-render to get the updated value. B…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@teilarer
Comment options

@codeBelt
Comment options

Answer selected by teilarer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants