-
Notifications
You must be signed in to change notification settings - Fork 109
Description
System Info
System:
OS: macOS 14.6.1
CPU: (12) arm64 Apple M2 Max
Memory: 4.78 GB / 96.00 GB
Shell: 5.9 - /bin/zsh
npmPackages:
@lynx-js/qrcode-rsbuild-plugin: workspace:* => 0.3.6
@lynx-js/react: workspace:* => 0.108.1
@lynx-js/react-rsbuild-plugin: workspace:* => 0.9.10
@lynx-js/rspeedy: workspace:* => 0.9.5
@lynx-js/types: ^3.3.0 => 3.3.0
Details
Currently, we would add a /*#__PURE__*/ to createSnapshot calls:
lynx-stack/packages/react/transform/src/swc_plugin_snapshot/mod.rs
Lines 1566 to 1574 in 985b305
| snapshot_create_call = match snapshot_create_call { | |
| Expr::Call(mut call) => { | |
| let pure_span = Span::dummy_with_cmt(); | |
| self.comments.add_pure_comment(pure_span.lo); | |
| call.span = pure_span; | |
| Expr::Call(call) | |
| } | |
| _ => unreachable!(), | |
| }; |
This would cause error if a JSX (or snapshot) is created in a background-only context. The following errors could happen:
-
main-thread.js exception: cannot read property 'update' of undefined
this.__snapshot_def.update![index]!(this, index, oldValue); -
main-thread.js exception: cannot convert to object
const { create, slot, isListHolder, cssId, entryName } = this.__snapshot_def;
Reproduce link
No response
Reproduce Steps
import { useState, useEffect } from '@lynx-js/react'
export function App() {
const [jsx, setJSX] = useState(null)
useEffect(() => {
setJSX(<text>Hello ReactLynx</text>)
})
return <view>{jsx}</view>
}Metadata
Metadata
Assignees
Labels
Type
Projects
Status