Skip to content

Commit 0490d52

Browse files
authored
Update react-native, React, and refactor some things (#239)
* Update react-native, React, and refactor some things * v3 refactor * Apply latest ref pattern to user-provided callbacks * Memoize image source to avoid JSON.stringify * Update hook tests * Update changeset * npm pkg fix
1 parent 62b1b46 commit 0490d52

File tree

9 files changed

+842
-1941
lines changed

9 files changed

+842
-1941
lines changed

.changeset/quick-cats-move.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
'react-native-responsive-image-view': major
3+
---
4+
5+
Update react-native, React, and refactor some things.
6+
7+
### Breaking Changes
8+
9+
#### Component Import
10+
11+
- The `ResponsiveImageView` component is now a named export instead of the default export. Migrate easily:
12+
13+
```diff
14+
-import ResponsiveImageView from 'react-native-responsive-image-view';
15+
+import { ResponsiveImageView } from 'react-native-responsive-image-view';
16+
```
17+
18+
- You shouldn't have to memoize the `onLoad` and `onError` callbacks anymore if you were doing so previously.
19+
20+
#### TypeScript
21+
22+
- `ResponsiveImageViewProps` is now a type rather than an interface (should only impact you if you were extending it)
23+
- `ResponsiveImageView` return type changed from `React.ReactElement<ResponsiveImageViewProps> | null` to `React.JSX.Element | null` which is more accurate
24+
- New `UseResponsiveImageViewOptions` type for hook options

README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ appropriate for your project.
7676

7777
### Component
7878

79-
```jsx
80-
import React from 'react';
79+
```tsx
80+
import * as React from 'react';
8181
import { Image, View } from 'react-native';
82-
import ResponsiveImageView from 'react-native-responsive-image-view';
82+
import { ResponsiveImageView } from 'react-native-responsive-image-view';
8383

84-
export default function MyComponent({ imageUri }) {
84+
function MyComponent({ imageUri }) {
8585
return (
8686
<ResponsiveImageView source={{ uri: imageUri }}>
8787
{({ getViewProps, getImageProps }) => (
@@ -104,15 +104,13 @@ render the `Image` inside the `View` in your `render` function.
104104
105105
### Hook
106106

107-
```jsx
108-
import React from 'react';
107+
```tsx
108+
import * as React from 'react';
109109
import { Image, View } from 'react-native';
110110
import { useResponsiveImageView } from 'react-native-responsive-image-view';
111111

112-
export default function MyComponent({ imageUri }) {
113-
const { getViewProps, getImageProps } = useResponsiveImageView({
114-
source: { uri: imageUri },
115-
});
112+
function MyComponent({ imageUri }) {
113+
const { getViewProps, getImageProps } = useResponsiveImageView({ source: { uri: imageUri } });
116114

117115
return (
118116
<View {...getViewProps()}>
@@ -171,7 +169,7 @@ It's just a function or component, available in a few different ways. Read Donav
171169
opinionated but informative [post about them][faccs-and-ci] for more information. They all receive
172170
the same props, so it is purely a stylistic choice left up to you as the consumer.
173171

174-
```jsx
172+
```tsx
175173
// component injection
176174
<ResponsiveImageView component={/* right here */} />
177175

0 commit comments

Comments
 (0)