mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-23 23:27:26 +01:00
Merge pull request #3258 from BlueWallet/navwarning
FIX: React Nav would throw a warning when passing a func to setParams
This commit is contained in:
commit
1e9a9c3cdf
1 changed files with 9 additions and 25 deletions
|
@ -4,7 +4,7 @@ import { BluePrivateBalance } from '../../BlueComponents';
|
||||||
import SortableList from 'react-native-sortable-list';
|
import SortableList from 'react-native-sortable-list';
|
||||||
import LinearGradient from 'react-native-linear-gradient';
|
import LinearGradient from 'react-native-linear-gradient';
|
||||||
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
|
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
|
||||||
import { useNavigation, useTheme } from '@react-navigation/native';
|
import { useTheme } from '@react-navigation/native';
|
||||||
|
|
||||||
import navigationStyle from '../../components/navigationStyle';
|
import navigationStyle from '../../components/navigationStyle';
|
||||||
import { PlaceholderWallet, LightningCustodianWallet, MultisigHDWallet } from '../../class';
|
import { PlaceholderWallet, LightningCustodianWallet, MultisigHDWallet } from '../../class';
|
||||||
|
@ -75,7 +75,6 @@ const ReorderWallets = () => {
|
||||||
const [hasMovedARow, setHasMovedARow] = useState(false);
|
const [hasMovedARow, setHasMovedARow] = useState(false);
|
||||||
const [scrollEnabled, setScrollEnabled] = useState(true);
|
const [scrollEnabled, setScrollEnabled] = useState(true);
|
||||||
const sortableList = useRef();
|
const sortableList = useRef();
|
||||||
const { setParams, goBack } = useNavigation();
|
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
const { wallets, setWalletsWithNewOrder } = useContext(BlueStorageContext);
|
const { wallets, setWalletsWithNewOrder } = useContext(BlueStorageContext);
|
||||||
const stylesHook = {
|
const stylesHook = {
|
||||||
|
@ -88,25 +87,15 @@ const ReorderWallets = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setParams(
|
if (sortableList.current?.state.data.length === data.length && hasMovedARow) {
|
||||||
{
|
|
||||||
customCloseButtonFunction: async () => {
|
|
||||||
if (sortableList.current.state.data.length === data.length && hasMovedARow) {
|
|
||||||
const newWalletsOrderArray = [];
|
const newWalletsOrderArray = [];
|
||||||
sortableList.current.state.order.forEach(element => {
|
sortableList.current.state.order.forEach(element => {
|
||||||
newWalletsOrderArray.push(data[element]);
|
newWalletsOrderArray.push(data[element]);
|
||||||
});
|
});
|
||||||
setWalletsWithNewOrder(newWalletsOrderArray);
|
setWalletsWithNewOrder(newWalletsOrderArray);
|
||||||
goBack();
|
|
||||||
} else {
|
|
||||||
goBack();
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
},
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [goBack, hasMovedARow, setParams]);
|
}, [hasMovedARow]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadWallets = wallets.filter(wallet => wallet.type !== PlaceholderWallet.type);
|
const loadWallets = wallets.filter(wallet => wallet.type !== PlaceholderWallet.type);
|
||||||
|
@ -202,11 +191,6 @@ const ReorderWallets = () => {
|
||||||
ReorderWallets.navigationOptions = navigationStyle(
|
ReorderWallets.navigationOptions = navigationStyle(
|
||||||
{
|
{
|
||||||
closeButton: true,
|
closeButton: true,
|
||||||
closeButtonFunc: ({ navigation, route }) => {
|
|
||||||
if (route.params && route.params.customCloseButtonFunction) {
|
|
||||||
route.params.customCloseButtonFunction();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
headerLeft: null,
|
headerLeft: null,
|
||||||
},
|
},
|
||||||
opts => ({ ...opts, title: loc.wallets.reorder_title }),
|
opts => ({ ...opts, title: loc.wallets.reorder_title }),
|
||||||
|
|
Loading…
Add table
Reference in a new issue