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

react-native-svg not working with react native web #2205

Closed
Prashant-Mobile-Server opened this issue Jan 11, 2024 · 7 comments
Closed

react-native-svg not working with react native web #2205

Prashant-Mobile-Server opened this issue Jan 11, 2024 · 7 comments
Labels
Close when stale This issue is going to be closed when there is no activity for a while Missing repro This issue need minimum repro scenario

Comments

@Prashant-Mobile-Server
Copy link

Prashant-Mobile-Server commented Jan 11, 2024

Getting error when trying to load svg image from a local directory. It is working fine on mobile but has below issue when I try to run for web.

ERROR
Uncaught runtime errors:
×
ERROR
The string contains invalid characters.
createElement@[native code]
createElement@
createInstance@
completeWork@
completeUnitOfWork@
performUnitOfWork@
workLoopSync@
renderRootSync@
recoverFromConcurrentError@
performConcurrentWorkOnRoot@
workLoop@
flushWork@
performWorkUntilDeadline@

Made below changes to support on mobile:

custom.d.ts:

declare module '*.svg' {
  const content: React.FunctionComponent<React.SVGAttributes<SVGElement>>;
  export default content;
}

tsconfig.json:

{
  "compilerOptions": {
    "jsx": "react"
  },
  "extends": "@tsconfig/react-native/tsconfig.json",

  "include": ["**/*.ts", "**/*.tsx", "custom.d.ts"]
}

@bohdanprog
Copy link
Member

Hello @Prashant-Mobile-Server ,
Can you share the example to reproduce that issue?
Thank you

@bohdanprog bohdanprog added Missing repro This issue need minimum repro scenario Close when stale This issue is going to be closed when there is no activity for a while labels Jun 12, 2024
@github-actions github-actions bot closed this as completed Jul 3, 2024
@jkoutavas
Copy link

Here's an example of the failure: jkoutavas/react-native-web-sandbox#1. Can we re-open this issue please?

@jkoutavas
Copy link

@bohdanprog

@bohdanprog
Copy link
Member

Hello @jkoutavas,
I checked your example, but you didn't use react-native-svg in your repository.
Also if you want to show SVG from file read that please.

@jkoutavas
Copy link

@bohdanprog please see the PR branch :-)

@bohdanprog
Copy link
Member

@jkoutavas Did you read that :) ?

@jkoutavas
Copy link

@Prashant-Mobile-Server for what it's worth, I have a working example here: jkoutavas/react-native-web-sandbox#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Close when stale This issue is going to be closed when there is no activity for a while Missing repro This issue need minimum repro scenario
Projects
None yet
Development

No branches or pull requests

3 participants