diff --git a/App.tsx b/App.tsx index 8322053..5029abe 100644 --- a/App.tsx +++ b/App.tsx @@ -1,17 +1,17 @@ import React from 'react'; import { NavigationContainer } from '@react-navigation/native'; -import { RecoilRoot } from 'recoil'; import SplashPage from './src/components/SplashPage'; import RootNavigator from './src/components/navigation/RootNavigator'; +import { Provider } from 'jotai'; const App = () => ( - + - + ); export default App; diff --git a/index.js b/index.js index 5cc85db..a327443 100644 --- a/index.js +++ b/index.js @@ -1,11 +1,6 @@ import 'react-native-gesture-handler'; import 'react-native-get-random-values'; -import { AppRegistry, LogBox } from 'react-native'; -// ignore recoil's timer warning on android: -// https://github.com/facebookexperimental/Recoil/issues/1030 -LogBox.ignoreLogs(["timer"]); - import { enableScreens } from 'react-native-screens'; enableScreens(); diff --git a/package-lock.json b/package-lock.json index 0321e3b..0360d70 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@react-navigation/material-top-tabs": "^5.3.15", "@react-navigation/native": "^5.9.4", "@react-navigation/stack": "^5.14.5", + "jotai": "^1.1.0", "md5": "^2.3.0", "react": "17.0.1", "react-native": "0.64.1", @@ -27,7 +28,6 @@ "react-native-screens": "^3.4.0", "react-native-tab-view": "^2.16.0", "react-native-track-player": "^1.2.7", - "recoil": "^0.3.1", "uuid": "^8.3.2", "xmldom": "^0.5.0" }, @@ -6116,11 +6116,6 @@ "dev": true, "optional": true }, - "node_modules/hamt_plus": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/hamt_plus/-/hamt_plus-1.0.2.tgz", - "integrity": "sha1-4hwlKWjH4zsg9qGwlM2FeHomVgE=" - }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -8461,6 +8456,47 @@ "@sideway/pinpoint": "^2.0.0" } }, + "node_modules/jotai": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jotai/-/jotai-1.1.0.tgz", + "integrity": "sha512-+c/bMxS/c1LgsOYVfevOYLAu+WEgn85TJhmBoNSNHjMV+mTKZY0ACSyCrX1yz8KialK4+Ggm6d7Ek3sTXy8UgA==", + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "@urql/core": "*", + "immer": "*", + "optics-ts": "*", + "react": ">=16.8", + "react-query": "*", + "valtio": "*", + "wonka": "*", + "xstate": "*" + }, + "peerDependenciesMeta": { + "@urql/core": { + "optional": true + }, + "immer": { + "optional": true + }, + "optics-ts": { + "optional": true + }, + "react-query": { + "optional": true + }, + "valtio": { + "optional": true + }, + "wonka": { + "optional": true + }, + "xstate": { + "optional": true + } + } + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -10772,25 +10808,6 @@ "node": ">= 0.10" } }, - "node_modules/recoil": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/recoil/-/recoil-0.3.1.tgz", - "integrity": "sha512-KNA3DRqgxX4rRC8E7fc6uIw7BACmMPuraIYy+ejhE8tsw7w32CetMm8w7AMZa34wzanKKkev3vl3H7Z4s0QSiA==", - "dependencies": { - "hamt_plus": "1.0.2" - }, - "peerDependencies": { - "react": ">=16.13.1" - }, - "peerDependenciesMeta": { - "react-dom": { - "optional": true - }, - "react-native": { - "optional": true - } - } - }, "node_modules/regenerate": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", @@ -17936,11 +17953,6 @@ "dev": true, "optional": true }, - "hamt_plus": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/hamt_plus/-/hamt_plus-1.0.2.tgz", - "integrity": "sha1-4hwlKWjH4zsg9qGwlM2FeHomVgE=" - }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -19673,6 +19685,12 @@ "@sideway/pinpoint": "^2.0.0" } }, + "jotai": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jotai/-/jotai-1.1.0.tgz", + "integrity": "sha512-+c/bMxS/c1LgsOYVfevOYLAu+WEgn85TJhmBoNSNHjMV+mTKZY0ACSyCrX1yz8KialK4+Ggm6d7Ek3sTXy8UgA==", + "requires": {} + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -21513,14 +21531,6 @@ "resolve": "^1.1.6" } }, - "recoil": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/recoil/-/recoil-0.3.1.tgz", - "integrity": "sha512-KNA3DRqgxX4rRC8E7fc6uIw7BACmMPuraIYy+ejhE8tsw7w32CetMm8w7AMZa34wzanKKkev3vl3H7Z4s0QSiA==", - "requires": { - "hamt_plus": "1.0.2" - } - }, "regenerate": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", diff --git a/package.json b/package.json index 9fdb9dd..e6706cf 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "@react-navigation/material-top-tabs": "^5.3.15", "@react-navigation/native": "^5.9.4", "@react-navigation/stack": "^5.14.5", + "jotai": "^1.1.0", "md5": "^2.3.0", "react": "17.0.1", "react-native": "0.64.1", @@ -29,7 +30,6 @@ "react-native-screens": "^3.4.0", "react-native-tab-view": "^2.16.0", "react-native-track-player": "^1.2.7", - "recoil": "^0.3.1", "uuid": "^8.3.2", "xmldom": "^0.5.0" }, diff --git a/src/components/ArtistsList.tsx b/src/components/ArtistsList.tsx index 22dea90..2d6eb52 100644 --- a/src/components/ArtistsList.tsx +++ b/src/components/ArtistsList.tsx @@ -1,8 +1,8 @@ import React from 'react'; -import { Button, FlatList, Text, View } from 'react-native'; -import { useRecoilValue, useResetRecoilState } from 'recoil'; +import { FlatList, Text, View } from 'react-native'; +import { useAtomValue } from 'jotai/utils'; import { Artist } from '../models/music'; -import { artistsState } from '../state/music'; +import { artistsAtom } from '../state/music'; const ArtistItem: React.FC<{ item: Artist } > = ({ item }) => ( @@ -15,7 +15,7 @@ const ArtistItem: React.FC<{ item: Artist } > = ({ item }) => ( ); const List = () => { - const artists = useRecoilValue(artistsState); + const artists = useAtomValue(artistsAtom); const renderItem: React.FC<{ item: Artist }> = ({ item }) => ( @@ -30,24 +30,10 @@ const List = () => { ); } -const ListPlusControls = () => { - const resetArtists = useResetRecoilState(artistsState); - - return ( - -