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:
GLaDOS 2021-06-06 20:10:11 +01:00 committed by GitHub
commit 1e9a9c3cdf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 }),