From 6a54fe2f44feeed18a555956bc75fa4ee1b2fbc8 Mon Sep 17 00:00:00 2001 From: ainsausti Date: Tue, 13 Feb 2018 12:15:03 +0100 Subject: [PATCH 1/4] Compatibilty with react-native and updated usage docs --- README.md | 7 +++---- package.json | 1 + src/index.native.js | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 src/index.native.js diff --git a/README.md b/README.md index 6a6707b..0cf7ba7 100644 --- a/README.md +++ b/README.md @@ -13,16 +13,15 @@ resolve: { alias: { 'react-native': 'react-native-web', ... - 'FlatList': 'react-native-web-lists/src/FlatList', - 'SectionList': 'react-native-web-lists/src/SectionList', + 'WebLists': 'react-native-web-lists', } } ``` ## Usage ```js -import FlatList from 'FlatList'; // don't import from react-native -import SectionList from 'SectionList'; // don't import from react-native +import { FlatList } from 'WebLists'; // don't import from react-native +import { SectionList } from 'WebLists'; // don't import from react-native ``` See [RN's docs](https://facebook.github.io/react-native/docs/flatlist.html). diff --git a/package.json b/package.json index f5e9c79..c2d1734 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.1.1", "description": "React Native for Web implementation of Lists", "main": "src/index.js", + "react-native": "src/index.native.js", "repository": { "type": "git", "url": "git@github.com:react-native-web-community/react-native-web-lists.git" diff --git a/src/index.native.js b/src/index.native.js new file mode 100644 index 0000000..74addc0 --- /dev/null +++ b/src/index.native.js @@ -0,0 +1 @@ +export { FlatList, SectionList } from "react-native"; \ No newline at end of file From 09e6ec926a7996a45d06fa0079801406264b3f39 Mon Sep 17 00:00:00 2001 From: ainsausti Date: Tue, 13 Feb 2018 12:52:16 +0100 Subject: [PATCH 2/4] Updated usage docs --- README.md | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 0cf7ba7..d0ad904 100644 --- a/README.md +++ b/README.md @@ -6,22 +6,13 @@ This package uses the legacy implementation (ListView). ## Getting started `$ npm install react-native-web-lists --save` -Alias the package in your webpack config: - -``` -resolve: { - alias: { - 'react-native': 'react-native-web', - ... - 'WebLists': 'react-native-web-lists', - } -} -``` ## Usage +Note: This implementation will work on Android and iOS because in `index.native.js` the default classes are exported from `react-native` + ```js -import { FlatList } from 'WebLists'; // don't import from react-native -import { SectionList } from 'WebLists'; // don't import from react-native +import { FlatList } from 'react-native-web-lists'; // don't import from react-native +import { SectionList } from 'react-native-web-lists'; // don't import from react-native ``` See [RN's docs](https://facebook.github.io/react-native/docs/flatlist.html). From 6af420502816c6dae639a65c0e9d99da6429a3c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Legan=C3=A9s-Combarro?= Date: Thu, 15 Feb 2018 14:03:31 +0100 Subject: [PATCH 3/4] Fixed exports to allow destructuring --- src/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 993c710..5d3dfdf 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,5 @@ import FlatList from './FlatList'; import SectionList from './SectionList'; -export default { FlatList, SectionList }; +export FlatList; +export SectionList; From 15574f74a7cef623ea3dc87faff2faa2b54e8b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Legan=C3=A9s-Combarro?= Date: Thu, 15 Feb 2018 14:14:47 +0100 Subject: [PATCH 4/4] Fixed destructured exports --- src/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 5d3dfdf..64d49ad 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,4 @@ import FlatList from './FlatList'; import SectionList from './SectionList'; -export FlatList; -export SectionList; +export {FlatList, SectionList};