-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Eliminate the creation of source arrays on every render - Export the `Image` component by default - Minor changes to exported typings - Deprecate named `ImageLoader` import - Update prettier/eslint configs - Update example app
- Loading branch information
Showing
12 changed files
with
157 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
arrowParens: 'avoid', | ||
bracketSameLine: true, | ||
bracketSpacing: false, | ||
singleQuote: true, | ||
trailingComma: 'all', | ||
}; |
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
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,35 @@ | ||
import {render} from '@testing-library/react-native'; | ||
|
||
import Image from './Image'; | ||
|
||
describe('Image', () => { | ||
const workingSource = {uri: 'https://ui-avatars.com/api/?name=John+Doe'}; | ||
// const brokenSource = { | ||
// uri: 'https://ui-avatars.com/api/?name=John+Doe&broken', | ||
// }; | ||
|
||
const workingFallback = {uri: 'https://ui-avatars.com/api/?name=Jane+Doe'}; | ||
const brokenFallback = { | ||
uri: 'https://ui-avatars.com/api/?name=Jane+Doe&broken', | ||
}; | ||
const fallbacks = [workingFallback, brokenFallback]; | ||
|
||
it('renders correctly with source', () => { | ||
const {toJSON} = render(<Image source={workingSource} />); | ||
expect(toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders correctly with fallback', () => { | ||
const {toJSON} = render( | ||
<Image source={workingSource} fallback={workingFallback} /> | ||
); | ||
expect(toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders correctly with fallbacks', () => { | ||
const {toJSON} = render( | ||
<Image source={workingSource} fallback={fallbacks} /> | ||
); | ||
expect(toJSON()).toMatchSnapshot(); | ||
}); | ||
}); |
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
33 changes: 33 additions & 0 deletions
33
...r/__snapshots__/ImageLoader.test.tsx.snap → ...s/Image/__snapshots__/Image.test.tsx.snap
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,2 @@ | ||
export {default} from './Image'; | ||
export * from './Image'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './ImageLoader'; | ||
export {default} from './Image'; | ||
export * from './Image'; |
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 |
---|---|---|
@@ -1,2 +1,15 @@ | ||
import Image from './components/Image'; | ||
|
||
// Export all the components | ||
export * from './components'; | ||
|
||
/** | ||
* @deprecated Use default export instead | ||
* import Image from 'react-native-image-fallback'; | ||
* | ||
* This is added for backwards compatibility and will be removed on the next major version. | ||
*/ | ||
const ImageLoader = Image; | ||
export {ImageLoader}; | ||
|
||
export default Image; |