Fix/style not match (#6521)

* fix: fix style not match when hydrate

* chore: add changeset
This commit is contained in:
染陌同学 2023-09-08 14:11:40 +08:00 committed by GitHub
parent b748810588
commit a04cc00242
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -0,0 +1,5 @@
---
'@ice/cache-canvas': patch
---
fix: fix style not match when hydrate

View File

@ -119,10 +119,9 @@ export const CacheCanvas = forwardRef((props: CacheCanvasProps, ref) => {
{ {
(typeof fallback === 'function') && (<div (typeof fallback === 'function') && (<div
id={`fallback-${id}`} id={`fallback-${id}`}
style={isNode || Storage.getItem(cacheKey, { bizID }) ? { display: 'none' } : { display: 'block' }}
> >
{ {
fallback() (isNode || !Storage.getItem(cacheKey, { bizID })) && fallback()
} }
</div>) </div>)
} }
@ -155,9 +154,9 @@ export const CacheCanvas = forwardRef((props: CacheCanvasProps, ref) => {
if (base64Data) { if (base64Data) {
const img = document.getElementById('canvas-img-${id}'); const img = document.getElementById('canvas-img-${id}');
img && (img.src = base64Data); img && (img.src = base64Data);
fallback && (fallback.style.display = 'none'); if (fallback && fallback.childNodes[0]) {
} else { fallback.removeChild(fallback.childNodes[0]);
fallback && (fallback.style.display = 'block'); }
} }
`, `,
}} }}