File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
packages/react/src/components/BackgroundImage Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ const BackgroundImage = forwardRef<Handle, BackgroundImageProps>(
3939 const backgroundImageRef = useRef < FabricImage | null > ( null )
4040
4141 const store = useStoreApi ( )
42+ const newestSrcRef = useRef ( src )
4243
4344 const { width, height } = useStore ( selector )
4445
@@ -132,13 +133,14 @@ const BackgroundImage = forwardRef<Handle, BackgroundImageProps>(
132133 }
133134 const { domNode, setLoading } = store . getState ( )
134135 setLoading ( true )
136+ newestSrcRef . current = src
137+
135138 FabricImage . fromURL ( src , { crossOrigin : 'anonymous' } )
136139 . then ( imageSource => {
137140 onLoad ?.( imageSource )
138141 const currentSrc = imageSource . getSrc ( )
139- const latestSrc = backgroundImageRef . current ?. getSrc ( )
140142
141- if ( latestSrc && currentSrc !== latestSrc ) {
143+ if ( currentSrc !== newestSrcRef . current ) {
142144 return
143145 }
144146
You can’t perform that action at this time.
0 commit comments