-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SvgUri can set state after unmount #1706
Comments
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.
|
getting the error too with a component like this
|
Same here. But the error didn't say where, took forever to pinpoint it to SvgUri. |
any updates on this? |
import React, { useEffect, useState } from 'react';
import { UriProps, SvgXml } from 'react-native-svg';
export function SvgUri(props: UriProps) {
const [xml, setXml] = useState<null | string>(null);
useEffect(
function fetchXml() {
const fetchController = new AbortController();
if (props.uri !== null)
fetch(props.uri, { signal: fetchController.signal })
.then((response) => response.text())
.then(setXml);
return () => fetchController.abort();
},
[props.uri]
);
return <SvgXml xml={xml} override={props} />;
} here is a solution derived from @Balintataw's |
Hello, |
Using 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?
The text was updated successfully, but these errors were encountered: