Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ReactotronConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Reactotron from 'reactotron-react-native';
import {AsyncStorage} from 'react-native';

Reactotron.setAsyncStorageHandler(AsyncStorage) // AsyncStorage would either come from `react-native` or `@react-native-community/async-storage` depending on where you get it from
.configure() // controls connection & communication settings
.useReactNative() // add all built-in react native plugins
.connect(); // let's connect!
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import App from './App';
import {name as appName} from './app.json';
import AuthProvider from './src/lib/context/AuthContext/AuthContextProvider';

if (__DEV__) {
import('./ReactotronConfig').then(() => console.log('Reactotron Configured'));
}

const AppProviders = () => (
<AuthProvider>
<App />
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"eslint": "7.14.0",
"jest": "26.6.3",
"metro-react-native-babel-preset": "0.64.0",
"react-test-renderer": "17.0.1"
"react-test-renderer": "17.0.1",
"reactotron-react-native": "^5.0.0"
},
"jest": {
"preset": "react-native"
Expand Down
28 changes: 23 additions & 5 deletions src/screens/HomeScreen.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,46 @@
import React, {useEffect, useState} from 'react';
import {FlatList, StyleSheet} from 'react-native';
import config from 'react-native-config';
import Reactotron from 'reactotron-react-native';

import VerticalImageIndex from '../components/VerticalImageIndex';

const HomeScreen = () => {
const [photos, setPhotos] = useState(null);
const [photos, setPhotos] = useState([]);
const [pageNumber, setPageNumber] = useState(1);

useEffect(() => {
loadPhotos();
}, []);

const loadPhotos = () => {
fetch(
`https://api.unsplash.com/photos/?client_id=${config.UNSPLASH_APP_CLIENT_ID}`,
`https://api.unsplash.com/photos/?client_id=${config.UNSPLASH_APP_CLIENT_ID}&page=${pageNumber}`,
)
.then(response => response.json())
.then(data => {
setPhotos(data);
const photosArray = [...photos, ...data];

setPhotos(photosArray);
setPageNumber(pageNumber + 1);
})
.catch(e => {
alert(e.message);
});
}, []);
};

const renderPhotos = ({item}) => {
return <VerticalImageIndex photo={item} />;
};

return (
<FlatList data={photos} style={styles.flatList} renderItem={renderPhotos} />
<FlatList
data={photos}
style={styles.flatList}
onEndReached={loadPhotos}
onEndReachedThreshold={0.5}
renderItem={renderPhotos}
/>
);
};

Expand Down
41 changes: 41 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4810,6 +4810,11 @@ minimist@^1.1.1, minimist@^1.2.0, minimist@^1.2.5:
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==

mitt@1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/mitt/-/mitt-1.1.3.tgz#528c506238a05dce11cd914a741ea2cc332da9b8"
integrity sha512-mUDCnVNsAi+eD6qA0HkRkwYczbLHJ49z17BGe2PYRhZL4wpZUFZGJHU7/5tmvohoma+Hdn0Vh/oJTiPEmgSruA==

mixin-deep@^1.2.0:
version "1.3.2"
resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566"
Expand Down Expand Up @@ -5428,6 +5433,15 @@ qs@~6.5.2:
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==

query-string@6.10.1:
version "6.10.1"
resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.10.1.tgz#30b3505f6fca741d5ae541964d1b3ae9dc2a0de8"
integrity sha512-SHTUV6gDlgMXg/AQUuLpTiBtW/etZ9JT6k6RCtCyqADquApLX0Aq5oK/s5UeTUAWBG50IExjIr587GqfXRfM4A==
dependencies:
decode-uri-component "^0.2.0"
split-on-first "^1.0.0"
strict-uri-encode "^2.0.0"

query-string@^6.13.6:
version "6.14.1"
resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.14.1.tgz#7ac2dca46da7f309449ba0f86b1fd28255b0c86a"
Expand Down Expand Up @@ -5475,6 +5489,11 @@ react-native-config@^1.4.2:
resolved "https://registry.yarnpkg.com/react-native-config/-/react-native-config-1.4.2.tgz#cc39f22ed72c5cb06af1adf0ba70ef01593900b4"
integrity sha512-iTvCvThvFTH7SdiBcsxYtpLy86zglsh51ZBqFPPZ75tdrQMdlRnDNnb86kNjQf03KT0qs1nCMLRejfPMIim8iA==

react-native-flipper@^0.34.0:
version "0.34.0"
resolved "https://registry.yarnpkg.com/react-native-flipper/-/react-native-flipper-0.34.0.tgz#7df1f38ba5d97a9321125fe0fccbe47d99e6fa1d"
integrity sha512-48wgm29HJTOlZ0DibBsvXueEOY0EPIVL0wWKbwRfgrk86+luSEuLW3aZC50oJa95zSFb9qYShTV/6dWqh4Jamg==

react-native-gesture-handler@^1.10.3:
version "1.10.3"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-1.10.3.tgz#942bbf2963bbf49fa79593600ee9d7b5dab3cfc0"
Expand Down Expand Up @@ -5596,6 +5615,23 @@ react@17.0.1:
loose-envify "^1.1.0"
object-assign "^4.1.1"

reactotron-core-client@2.8.10:
version "2.8.10"
resolved "https://registry.yarnpkg.com/reactotron-core-client/-/reactotron-core-client-2.8.10.tgz#798f2a7aa9fd7e18e7a510531a613e8ae3008eb0"
integrity sha512-SYRO4OCutJzfWMnaULUGVyETZnMDCU5ECNflXyM3Z5Gnfxp/wV6d7jYonhfxHdpU/aGb4Eg15C22myOCXSu6HQ==

reactotron-react-native@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/reactotron-react-native/-/reactotron-react-native-5.0.0.tgz#e495630927cb720940f5d8cc7d768f162b32c1a7"
integrity sha512-7nLrMkLXU9jiHymbB6oBqf8z+vww1AbDcUdMmLqX0obdIHyC8XJB0yRazWajKQC92kamkL+q2q4mH9HRSsYCEA==
dependencies:
mitt "1.1.3"
query-string "6.10.1"
reactotron-core-client "2.8.10"
rn-host-detect "1.2.0"
optionalDependencies:
react-native-flipper "^0.34.0"

read-pkg-up@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-7.0.1.tgz#f3a6135758459733ae2b95638056e1854e7ef507"
Expand Down Expand Up @@ -5863,6 +5899,11 @@ rimraf@~2.2.6:
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.2.8.tgz#e439be2aaee327321952730f99a8929e4fc50582"
integrity sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=

rn-host-detect@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/rn-host-detect/-/rn-host-detect-1.2.0.tgz#8b0396fc05631ec60c1cb8789e5070cdb04d0da0"
integrity sha512-btNg5kzHcjZZ7t7mvvV/4wNJ9e3MPgrWivkRgWURzXL0JJ0pwWlU4zrbmdlz3HHzHOxhBhHB4D+/dbMFfu4/4A==

rsvp@^4.8.4:
version "4.8.5"
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734"
Expand Down