-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle error when pass wrong uri to SvgFromUri component (#2289)
# Summary We want to add the ability to handle the Error when someone passes the wrong URI to the `SvgFromUri` component. Closes #2148 ## Test Plan Manual tests in TestsExample app. (Test2148)
- Loading branch information
1 parent
1703399
commit 8733bea
Showing
3 changed files
with
31 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React, {useState} from 'react'; | ||
import {Text, View} from 'react-native'; | ||
import {SvgFromUri} from 'react-native-svg'; | ||
|
||
export default function App() { | ||
const [error, setError] = useState<Error>(); | ||
return ( | ||
<View style={{flex: 1, backgroundColor: 'red', padding: 50}}> | ||
<SvgFromUri | ||
uri={ | ||
'https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.svgrepo.com%2Fsvg%2F5154%2Fhand-pointer&psig=AOvVaw2e3ud_ho3oPjy1VSLw0nch&ust=1717666569513000&source=images&cd=vfe&opi=89978449&ved=0CBIQjRxqFwoTCLixjuCUxIYDFQAAAAAdAAAAABAY' | ||
} | ||
width={24} | ||
height={24} | ||
onError={setError} | ||
/> | ||
<Text style={{marginTop: 50, color: '#fff'}}>{error?.message}</Text> | ||
</View> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters