-
-
Notifications
You must be signed in to change notification settings - Fork 22
Fix optimistic update crash when following v2 docs #173
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
Fix optimistic update crash when following v2 docs #173
Conversation
|
@AlanFoster Do you still have a branch that reproduces this? I'm interested in digging into it. |
|
Of course! Replication steps: Code diff - i.e. reintroducing the option that this PR aims to remove: --- a/app/javascript/components/ItemsList.jsx
+++ b/app/javascript/components/ItemsList.jsx
@@ -8,6 +8,7 @@ const Item = ({ itemRef }) => {
name,
completed,
detailPath,
+ toggleForm
} = useContent(itemRef)
const set = useSetFragment()
@@ -51,4 +52,4 @@ export default function ItemsList({ itemsRef }) {
))}
</ul>
)Replication steps: Click the
Page will turn white; and the stack trace is in the console log: Let me know if there's anything else I can do to help 💯 |
|
Looking into this, this is a bug. I think... i'm returning a frozen object because of the use of immer in useSetFragment and that's causing the frozen violation. I'll have a fix for it soon. |
When using `useSetFragment`, the obj returned was frozen. This cause a javascript invariant violation which breaks the proxy leading to this error discovered on #173 ``` Uncaught TypeError: 'get' on proxy: property 'toggleForm' is a read-only and non-configurable data property on the proxy target but the proxy did not return its actual value (expected '#<Object>' but got '#<Object>') at Item (ItemsList.jsx:11:5) at Object.react_stack_bottom_frame (react-dom-client.development.js:23863:20) ... etc .. ``` The fix is to use a local instance of Immer and setting the auto freeze to false.
|
@AlanFoster I have a fix for that error for you encountered: #179 Thanks for reporting this! |
When using `useSetFragment`, the obj returned was frozen. This cause a javascript invariant violation which breaks the proxy leading to this error discovered on #173 ``` Uncaught TypeError: 'get' on proxy: property 'toggleForm' is a read-only and non-configurable data property on the proxy target but the proxy did not return its actual value (expected '#<Object>' but got '#<Object>') at Item (ItemsList.jsx:11:5) at Object.react_stack_bottom_frame (react-dom-client.development.js:23863:20) ... etc .. ``` The fix is to use a local instance of Immer and setting the auto freeze to false.
When using `useSetFragment`, the obj returned was frozen. This cause a javascript invariant violation which breaks the proxy leading to this error discovered on #173 ``` Uncaught TypeError: 'get' on proxy: property 'toggleForm' is a read-only and non-configurable data property on the proxy target but the proxy did not return its actual value (expected '#<Object>' but got '#<Object>') at Item (ItemsList.jsx:11:5) at Object.react_stack_bottom_frame (react-dom-client.development.js:23863:20) ... etc .. ``` The fix is to use a local instance of Immer and setting the auto freeze to false.
|
Closing this PR. A fix was released in 2.0.0-alpha.9. |
|
Confirmed as working now, thanks! |

Without this change, the following crash was observed locally when clicking the
togglebutton in the ItemsList component