Skip to content
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

Must SVGUri uri be http/https? Can use data: image/svg+XML; Base64 format #2142

Closed
suwu150 opened this issue Sep 21, 2023 · 0 comments
Closed

Comments

@suwu150
Copy link

suwu150 commented Sep 21, 2023

Feature Request

Must SVGUri uri be http/https? Can use data: image/svg+XML; Base64 format

Why it is needed

Need to directly pass base64 to SVG,I found that requests are made in the source code。

export function SvgUri(props: UriProps) {
  const { onError = err, uri, onLoad, fallback } = props;
  const [xml, setXml] = useState<string | null>(null);
  const [isError, setIsError] = useState(false);
  useEffect(() => {
    uri
      ? fetchText(uri)
          .then((data) => {
            setXml(data);
            isError && setIsError(false);
            onLoad?.();
          })
          .catch((e) => {
            onError(e);
            setIsError(true);
          })
      : setXml(null);
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [onError, uri, onLoad]);
  if (isError) {
    return fallback ?? null;
  }
  return <SvgXml xml={xml} override={props} fallback={fallback} />;
}

Code sample

jakex7 added a commit that referenced this issue Sep 24, 2024
# Summary
Feature #2142 

Add support for data: image/svg+XML; Base64 format.

## Test Plan
TestExample app -> src -> Test2142

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ✅      |
| MacOS   |    ✅      |
| Android |    ✅      |
| Web     |    ✅      |

---------

Co-authored-by: Jakub Grzywacz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants