Commit 560051cf authored by 郑云峰's avatar 郑云峰

chore: 讲useStores移动至hooks目录,清除不用的包

parent bbec5115
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
"expo-blur": "~8.2.0", "expo-blur": "~8.2.0",
"i18next": "^20.5.0", "i18next": "^20.5.0",
"mobx": "^6.7.0", "mobx": "^6.7.0",
"mobx-react": "^7.6.0",
"mobx-react-lite": "^3.4.0", "mobx-react-lite": "^3.4.0",
"qs": "^6.9.4", "qs": "^6.9.4",
"prettier": "^2.8.0", "prettier": "^2.8.0",
......
import React, { createContext, useContext } from 'react'; import React, { createContext, useContext } from 'react';
import { Store } from '.'; import { Store } from '../store';
const StoreContext = createContext<Store>(new Store()); const StoreContext = createContext<Store>(new Store());
...@@ -9,4 +9,8 @@ const StoreProvider = () => { ...@@ -9,4 +9,8 @@ const StoreProvider = () => {
return <StoreContext.Provider value={store}></StoreContext.Provider>; return <StoreContext.Provider value={store}></StoreContext.Provider>;
}; };
/**
* 自定义useStores hook,使用React Context共享整个store。
* @returns store实例
*/
export const useStores = () => useContext(StoreContext); export const useStores = () => useContext(StoreContext);
import React from 'react'; import React from 'react';
import { View, Button } from 'react-native'; import { View, Button } from 'react-native';
import { RootStackScreenProps } from '../../routers/types'; import { RootStackScreenProps } from '../../routers/types';
import { useStores } from '../../store/useStores'; import { useStores } from '../../hooks/useStores';
import { ContentItem } from './ContentItem'; import { ContentItem } from './ContentItem';
import { styles } from './styles'; import { styles } from './styles';
......
...@@ -4,7 +4,7 @@ import { View, Text, Image } from 'react-native'; ...@@ -4,7 +4,7 @@ import { View, Text, Image } from 'react-native';
// import ModeMobile from '@/components/Modemobile'; // import ModeMobile from '@/components/Modemobile';
import { setAsyncStorage } from '../../utils/storage'; import { setAsyncStorage } from '../../utils/storage';
import { encryptedByAES, decryptedByAES } from '../../utils/cryptoAes'; import { encryptedByAES, decryptedByAES } from '../../utils/cryptoAes';
import useStores from '../../store/useStores'; import { useStores } from '../../hooks/useStores';
import { import {
postMemberMobileWechatAppletLoginPhone, postMemberMobileWechatAppletLoginPhone,
postMemberMobileWechatAppletLoginAccount, postMemberMobileWechatAppletLoginAccount,
......
...@@ -3,7 +3,7 @@ import { StackScreenProps } from '@react-navigation/stack'; ...@@ -3,7 +3,7 @@ import { StackScreenProps } from '@react-navigation/stack';
import React from 'react'; import React from 'react';
import { View, Text } from 'react-native'; import { View, Text } from 'react-native';
import { RootTabScreenProps, RootStackParamList } from '../../routers/types'; import { RootTabScreenProps, RootStackParamList } from '../../routers/types';
import { useStores } from '../../store/useStores'; import { useStores } from '../../hooks/useStores';
import { styles } from './styles'; import { styles } from './styles';
type PersonalCenterNavigationProp = CompositeScreenProps< type PersonalCenterNavigationProp = CompositeScreenProps<
......
...@@ -5888,13 +5888,6 @@ mobx-react-lite@^3.4.0: ...@@ -5888,13 +5888,6 @@ mobx-react-lite@^3.4.0:
resolved "http://npm.shushangyun.com/mobx-react-lite/-/mobx-react-lite-3.4.0.tgz#d59156a96889cdadad751e5e4dab95f28926dfff" resolved "http://npm.shushangyun.com/mobx-react-lite/-/mobx-react-lite-3.4.0.tgz#d59156a96889cdadad751e5e4dab95f28926dfff"
integrity sha512-bRuZp3C0itgLKHu/VNxi66DN/XVkQG7xtoBVWxpvC5FhAqbOCP21+nPhULjnzEqd7xBMybp6KwytdUpZKEgpIQ== integrity sha512-bRuZp3C0itgLKHu/VNxi66DN/XVkQG7xtoBVWxpvC5FhAqbOCP21+nPhULjnzEqd7xBMybp6KwytdUpZKEgpIQ==
mobx-react@^7.6.0:
version "7.6.0"
resolved "http://npm.shushangyun.com/mobx-react/-/mobx-react-7.6.0.tgz#ebf0456728a9bd2e5c24fdcf9b36e285a222a7d6"
integrity sha512-+HQUNuh7AoQ9ZnU6c4rvbiVVl+wEkb9WqYsVDzGLng+Dqj1XntHu79PvEWKtSMoMj67vFp/ZPXcElosuJO8ckA==
dependencies:
mobx-react-lite "^3.4.0"
mobx@^6.7.0: mobx@^6.7.0:
version "6.7.0" version "6.7.0"
resolved "http://npm.shushangyun.com/mobx/-/mobx-6.7.0.tgz#2d805610fee1801fd015c54fd5400d2601aa3768" resolved "http://npm.shushangyun.com/mobx/-/mobx-6.7.0.tgz#2d805610fee1801fd015c54fd5400d2601aa3768"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment