SvgUri can set state after unmount
See original GitHub issueUsing v: 12.1.0 RN: 0.6.6.0
Essentially this part defining SvgUri can attempt to set state after the component has unmounted which will throw memory leak warnings with a call to setXml. Maybe need a mount safe setState hook?
export function SvgUri(props: UriProps) {
const { onError = err, uri } = props;
const [xml, setXml] = useState<string | null>(null);
useEffect(() => {
uri
? fetchText(uri)
.then(setXml)
.catch(onError)
: setXml(null);
}, [onError, uri]);
return <SvgXml xml={xml} override={props} />;
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:5
Top Results From Across the Web
SvgUri can set state after unmount · Issue #1706 - GitHub
Essentially this part defining SvgUri can attempt to set state after the component has unmounted which will throw memory leak warnings with ...
Read more >How to cancel SvgUri request when component will unmount
To fix, cancel all subscriptions and asynchronous task in "a useEffect cleanup function". My component is: import React, { useEffect } from ' ......
Read more >How to cancel SvgUri request when component will unmount ...
[Solved]-How to cancel SvgUri request when component will unmount-React Native. Search. score:0. import YourSvgFile from './YourSvgFile.svg'; <YourSvgFile />.
Read more >Prevent React setState on unmounted Component
How to avoid the React warning: Can only update a mounted or mounting component. It usually means you have called setState on an...
Read more >is it dangerous Can't perform a React state update on an ...
componentWillUnmount() { // fix Warning: Can't perform a React state update on an unmounted component this.setState = (state,callback)=>{ ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
getting the error too with a component like this
So far, patching with something like this works well for my case. fetchText is also used in conjunction with a setState call in the SvgFromUri class so this is just a temporary fix.