diff --git a/apps/common/test/Test2320.tsx b/apps/common/test/Test2320.tsx new file mode 100644 index 000000000..a160cc762 --- /dev/null +++ b/apps/common/test/Test2320.tsx @@ -0,0 +1,52 @@ +import React from 'react'; +import {Button, View} from 'react-native'; +import {Circle, Svg, SvgUri} from 'react-native-svg'; + +// https://github.com/software-mansion/react-native-svg/issues/2320 +// SvgUri (and the other URI components) accept an optional `headers` prop +// that is forwarded to the underlying fetch call, mirroring +// ImageURISource.headers. +export default () => { + const [uri, setUri] = React.useState(null); + + // Keep the headers object referentially stable so the effect does not + // re-run and re-fetch on every render. + const headers = React.useMemo( + () => ({ + Authorization: 'Bearer example-token', + 'X-Custom-Header': 'react-native-svg', + }), + [], + ); + + return ( + + + + {uri && ( + + )} + +