mirror of https://github.com/alibaba/ice.git
feat(runtime): add custom event for suspense data updates (#7112)
* feat(runtime): add custom event for suspense data updates * feat(runtime): remove ice-suspense custom event * chore(runtime): add changeset
This commit is contained in:
parent
22b10c0d1c
commit
1a0a2c1f61
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@ice/runtime': patch
|
||||
---
|
||||
|
||||
feat: Add custom event for suspense data updates, and remove ice-suspense custom event.
|
||||
|
|
@ -156,11 +156,6 @@ export function withSuspense(Component) {
|
|||
<SuspenseContext.Provider value={suspenseState}>
|
||||
<Component {...componentProps} />
|
||||
<Data id={id} />
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `window.dispatchEvent(new CustomEvent('ice-suspense', { detail: { id: ${id ? `'${id}'` : undefined} } }));`,
|
||||
}}
|
||||
/>
|
||||
</SuspenseContext.Provider>
|
||||
</React.Suspense>
|
||||
);
|
||||
|
|
@ -174,7 +169,7 @@ function Data(props) {
|
|||
<script
|
||||
id={props.id && `suspense-script-${props.id}`}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `!function(){window['${LOADER}'] = window['${LOADER}'] || {};window['${LOADER}']['${props.id}'] = ${JSON.stringify(data)}}();`,
|
||||
__html: `!function(){window['${LOADER}'] = window['${LOADER}'] || {};window['${LOADER}']['${props.id}'] = ${JSON.stringify(data)}}();window.dispatchEvent(new CustomEvent('ice-suspense-data', { detail: { id: ${props.id ? `'${props.id}'` : undefined} } }));`,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue