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

useReactive - read-only and non-configurable data property #1317

Closed
rimsila opened this issue Nov 20, 2021 · 7 comments · Fixed by #2247
Closed

useReactive - read-only and non-configurable data property #1317

rimsila opened this issue Nov 20, 2021 · 7 comments · Fixed by #2247
Assignees

Comments

@rimsila
Copy link

rimsila commented Nov 20, 2021

ahooks v2.10.12
can't access to record.rule it will showing error like picture below other wise like record.id is working fine. thanks you
Screen Shot 2021-11-20 at 2 53 54 PM
Screen Shot 2021-11-20 at 2 54 21 PM

@brickspert brickspert self-assigned this Nov 22, 2021
@brickspert
Copy link
Collaborator

Can you provide an example?I can’t reproduce this problem in my test:https://codesandbox.io/s/eager-resonance-ebbh8?file=/App.tsx

@rimsila
Copy link
Author

rimsila commented Nov 24, 2021

I not sure about that too maybe it error because of the data was not initial to useReactive (get from server) I can access to state.record.id but can't access tostate.record.rule maybe rule is object and very nested data. thanks you

@rimsila rimsila closed this as completed Nov 24, 2021
@rimsila rimsila reopened this Dec 19, 2021
@rimsila
Copy link
Author

rimsila commented Dec 19, 2021

Can you provide an example?I can’t reproduce this problem in my test:https://codesandbox.io/s/eager-resonance-ebbh8?file=/App.tsx

@brickspert In my case above I'm not sure the root cause but I have test I see new case when useReactive contain react element or form data it cause the error

'get' on proxy: property '_store' 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>')

here is my reproduce https://codesandbox.io/s/condescending-pateu-rkq85?file=/App.tsx

@askurat
Copy link

askurat commented Mar 9, 2022

Same issue here: If you set a property to a React component you will get this error.

@liuyib
Copy link
Collaborator

liuyib commented May 8, 2023

mark a test case:

const NonConfigurableObject = function createNonProxyableObject(): {user: {name: string}} {
  const obj = {}
  Reflect.defineProperty(obj, 'user', { 
    value: { name: "Alice" }, 
    writable: false, 
    configurable: false,
  })
  // Reflect.getOwnPropertyDescriptor(obj, 'user')
  // { value: {…}, writable: false, enumerable: true, configurable: false }
  return obj as any
}();

export default () => {
  const state = useReactive(NonConfigurableObject);

  return (
    <div>
      <div>{state.user.name}</div>
    </div>
  );
};

@liuyib
Copy link
Collaborator

liuyib commented May 8, 2023

这个暂时看无解,见排查过程:#2079 (comment), 后续慢慢研究

@liuyib
Copy link
Collaborator

liuyib commented Jul 5, 2023

This seems to work: patriksimek/vm2#62 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants