Skip to content

Commit

Permalink
Fix IdealImage trying to load() the picked image onEnter before the i…
Browse files Browse the repository at this point in the history
…mage url has been set to state.

Not sure why it worked before, but with React 18 this definitively fail, and it's not expected to be able to see your reads
  • Loading branch information
slorber committed May 31, 2023
1 parent f765a21 commit 0f5e688
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/IdealImage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,9 @@ export default class IdealImage extends Component {
...this.state, // eslint-disable-line react/no-access-state-in-setstate
size: pickedSrc.size,
})
this.setState({pickedSrc, shouldAutoDownload, url})
if (shouldAutoDownload) this.load(false)
this.setState({pickedSrc, shouldAutoDownload, url},() => {
if (shouldAutoDownload) this.load(false)
})
}

onLeave = () => {
Expand Down

0 comments on commit 0f5e688

Please sign in to comment.