refactor(components): [table] remove unnecessary reactivity#23254
Conversation
|
👋 @web3Worker-x, seems like this is your first time contribution to element-plus. |
📝 WalkthroughWalkthroughReplaced a Vue Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
Comment |
commit: |
|
🧪 Playground Preview: https://element-plus.run/?pr=23254 |
|
I’m not entirely clear about the scenario where this error occurs. Could you provide a simple reproducible example? Also, I think @webfanzc solution looks good #23257 (comment), What do you think? |
Yes, we don't need to use reactive programming here; using regular variables will work better. I'll adjust it to regular variable mode. |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/components/table/src/table/key-render-helper.ts
🔇 Additional comments (3)
packages/components/table/src/table/key-render-helper.ts (3)
1-1: LGTM: Removed unnecessaryrefimport.The removal of
refis appropriate since the observer is now managed as a plain variable, avoiding reactivity overhead and issues with MutationObserver's private properties.
8-18: LGTM: Observer initialization and usage pattern is correct.The direct initialization and usage of the plain variable properly avoids Vue's reactivity system, which resolves the issue with MutationObserver's private properties. The observer is created and immediately used within the same function scope, ensuring safe access.
25-27: LGTM: Proper cleanup with optional chaining.The cleanup logic correctly uses optional chaining to safely disconnect the observer, handling cases where the observer might not be initialized.
|
Could you provide a simple reproducible example? |
|
For example, if the class contains #msg, using ref will result in an error. |
Uncomment below and it will work normally without using ref. |
|
|
@web3Worker-x Thanks for your contribution! ❤️ |


Please make sure these boxes are checked before submitting your PR, thank you!
devbranch.If the MutationObserver class contains private properties marked with '#', using 'ref' will cause an error. Replace it with 'shallowRef' to avoid this error.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.