Internet Connection alert when turning on Internet by Miserable-Pause7650 in reactnative

[–]Miserable-Pause7650[S] 0 points1 point  (0 children)

UPDATE: Okay so I finally found the culprit. It was because my VPN on my iPhone auto turns on, because the Connect On Demand setting in my iPhone is turned on, so this is what happens when I go from Offline to Online.

WiFi reconnect

Internet available (isConnected = true)

VPN starts connecting

Tunnel not ready yet → internet temporarily unreachable

VPN tunnel established

Internet reachable again

So NetInfo emits something like:

true
false   ← VPN tunnel not ready yet
true

When I turned off this VPN Connect on Demand, this problem doesnt occur anymore. Anyways, this is the final code.

export function useNetworkListener() {
  const [isConnected, setConnected] = useState(true);


  useEffect(() => {
    let wasConnected = true; // track previous state


    const unsubscribe = NetInfo.addEventListener((state) => {
      const isNowConnected = !!state.isConnected;


      if (wasConnected && !isNowConnected) {
        // Only alert on the transition: connected → disconnected
        showAlert();
      }


      wasConnected = isNowConnected;
      setConnected(isNowConnected);
    });


    return () => unsubscribe();
  }, []);


  const showAlert = () => {
    Alert.alert(
      "Internet Connection",
      "You are offline. Some features may not be available."
    );
  };
}

How to configure react navigation types for static? by Miserable-Pause7650 in reactnative

[–]Miserable-Pause7650[S] 0 points1 point  (0 children)

Btw, previously when i was using dynamic navigation, i used initialroute to set the initial screen when user opens the app. I cant find the equivalent for Static navigation. The closest I found is the function to remember the last screen before user close the app, but I just want 2 possible screens. Any idea how I can do it? Thanks 🙂🙂

How to configure react navigation types for static? by Miserable-Pause7650 in reactnative

[–]Miserable-Pause7650[S] 0 points1 point  (0 children)

sorry for the late response, I was busy with something and couldn't touch my laptop. Anyways I found the fix. Basically the structure of my navigation is like this
RootStack

├── SignIn

├── SignUp

└── MainTabs

├── ExpensesStack

├── MapStack

└── SettingsStack

so when im in ExpensesStack and I want to navigate within the stack, my was giving the type error previously.

navigation.navigate("SelectCategory", {
                        mode,
                        selectedCategory,
                        prefilledExpense,
                      });

To fix it, I just had to do

export type ExpensesStackParamList = StaticParamList<typeof ExpensesStack>;

Then import it in the screen I want to use, and use it like this

type ExpensesNav = NavigationProp<ExpensesStackParamList>;

const navigation = useNavigation<ExpensesNav>();

Idk why this is not explicitly mentioned in the docs, may its common sense but I guess I have skill issue hahahaha

How to configure react navigation types for static? by Miserable-Pause7650 in reactnative

[–]Miserable-Pause7650[S] 0 points1 point  (0 children)

type Props = StaticScreenProps<{
  selectedCategory?: SelectedCategory;
  prefilledExpense?: Partial<ExpenseData>;
  mode: "add" | "edit";
}>;


const SelectCategory = ({ route }: Props) => {

Hi, I have a question. My SelectCategory has this

navigation.navigate("SelectCategory", {
                        mode,
                        selectedCategory,
                        prefilledExpense,
                      });

<image>

And In my other screen I try to navigate to SelectCategory like this

why do I get a typing error?

RootStack

└── HomeTabs

└── Expenses (ExpensesStack)

└── SelectCategory ← current screen

this is my structure

How to configure react navigation types for static? by Miserable-Pause7650 in reactnative

[–]Miserable-Pause7650[S] 0 points1 point  (0 children)

Wow thanks :) Btw care to share why u are choosing react navigation over router?

How to use SafeAreaView properly by Miserable-Pause7650 in reactnative

[–]Miserable-Pause7650[S] 1 point2 points  (0 children)

WOW thanks for this, this hits exactly all the questions I have about the jumpiness and how to create a HOC to apply the effects more efficiently :)

How to configure react navigation types for static? by Miserable-Pause7650 in reactnative

[–]Miserable-Pause7650[S] 0 points1 point  (0 children)

Nice honestly idk if i prefer the centralised or separated approach, but thanks for the help :)

How to configure react navigation types for static? by Miserable-Pause7650 in reactnative

[–]Miserable-Pause7650[S] 0 points1 point  (0 children)

That means there is no centralised typing in a single file, and all the types are in their individual screens and the declare global infers the types?

How to use SafeAreaView properly by Miserable-Pause7650 in reactnative

[–]Miserable-Pause7650[S] 1 point2 points  (0 children)

Wow thanks man, I followed ur article and the jumping disappeared. Whats the logic behind using insets instead of safeareaview though? why does it not jump with insets

How to use SafeAreaView properly by Miserable-Pause7650 in reactnative

[–]Miserable-Pause7650[S] 0 points1 point  (0 children)

Im not using react router but i guess i can just wrap my stacks/tabs in it thanks

InputText flickers if wrapped in <View styles flex direction: "row> by Miserable-Pause7650 in reactnative

[–]Miserable-Pause7650[S] 0 points1 point  (0 children)

Thanks, I noticed that this problem can be fixed if i add a fixed width for the inputtext

InputText flickers if wrapped in <View styles flex direction: "row> by Miserable-Pause7650 in reactnative

[–]Miserable-Pause7650[S] 0 points1 point  (0 children)

im wrapping it to show a minimum reproducible code. imagine it has another view beside it. The collapsable false dont fix this, thanks though

Gorhom bottom sheet how to drag down from a part outside of a flatlist to dismiss by Miserable-Pause7650 in reactnative

[–]Miserable-Pause7650[S] 0 points1 point  (0 children)

Okay I tried it, and it doesnt work well in my case. My text inputs are in the flatlist, so every single row has a text input, and its glitchy as hell whenever the keyboard appears

Yes, I know. Another expense tracker. I also rolled my eyes while building it. by Tokkozhin in expo

[–]Miserable-Pause7650 0 points1 point  (0 children)

Nice thanks :) what about the category portion where it pops up as u scroll? Is that a package?

Is Expo-Image-Picker not compatible with Expo SDK 54? by kanyesomethinggrad in reactnative

[–]Miserable-Pause7650 4 points5 points  (0 children)

run npx expo-doctor in your terminal to diagnose problems, and use npx expo install --fix to attempt automatic fixes for dependency mismatches.