Skip to content

Commit

Permalink
Fix compatibility issue with react-native-web on non-expo projects
Browse files Browse the repository at this point in the history
  • Loading branch information
NiciusB committed May 10, 2020
1 parent b430775 commit 827a0bd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ Drop-in RefreshControl component for web
npm i react-native-web-refresh-control
```

#### If you're using Expo
You don't need to change anything else

#### If you're NOT using Expo
You will need to configure webpack to parse JSX in `node_modules/react-native-web-refresh-control`.

1. Eject from `react-scripts` with `npm run eject`.
2. Modify the main `babel-loader` module in `config/webpack.config.js`.
* Replace `include: paths.appSrc,` with `include: [paths.appSrc, /node_modules\/react-native-web-refresh-control/],`

## Example

https://snack.expo.io/@niciusb/refreshcontrol-example
Expand All @@ -33,4 +43,4 @@ import App from './App'
patchFlatListProps()
registerRootComponent(App)
```
```
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-web-refresh-control",
"version": "1.0.1",
"version": "1.0.2",
"description": "An implementation of React Native's RefreshControl for web, since react-native-web currently does not provide one",
"main": "src/index.js",
"scripts": {
Expand Down
11 changes: 4 additions & 7 deletions src/RefreshControl.web.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {
Animated,
ActivityIndicator,
findNodeHandle,
ViewPropTypes,
ColorPropType,
} from 'react-native'
import PropTypes from 'prop-types'

Expand Down Expand Up @@ -170,17 +168,16 @@ function RefreshControl({
}

RefreshControl.propTypes = {
...ViewPropTypes,
colors: PropTypes.arrayOf(ColorPropType),
colors: PropTypes.array,
enabled: PropTypes.bool,
onRefresh: PropTypes.func,
progressBackgroundColor: ColorPropType,
progressBackgroundColor: PropTypes.any,
progressViewOffset: PropTypes.number,
refreshing: PropTypes.bool.isRequired,
size: PropTypes.oneOf(['small', 'large']),
tintColor: ColorPropType,
tintColor: PropTypes.any,
title: PropTypes.string,
titleColor: ColorPropType,
titleColor: PropTypes.any,
}

export default RefreshControl
Expand Down

0 comments on commit 827a0bd

Please sign in to comment.