Skip to content

Commit

Permalink
fix: refetch useeffect dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisCusihuaman committed Nov 18, 2023
1 parent 1b9f26d commit cf50fce
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/screens/feed/comment-list.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useNavigation } from '@react-navigation/native';
import type { AxiosInstance } from 'axios';
import React, { useState } from 'react';
import React from 'react';
import { FlatList, RefreshControl } from 'react-native';

import type { Snap } from '@/api';
Expand Down Expand Up @@ -32,7 +32,7 @@ export const Comments = ({
const { navigate } = useNavigation();

// State to track the number of items to render
const [renderCount, setRenderCount] = useState(INITIAL_RENDER);
const [renderCount, setRenderCount] = React.useState(INITIAL_RENDER);

// Corrected renderItem function
const renderItem = ({ item, index }: { item: Snap; index: number }) => {
Expand Down Expand Up @@ -70,12 +70,12 @@ export const Comments = ({
);
}

const [refresh, setRefresh] = useState(false);
const [refresh, setRefresh] = React.useState(false);

let onRefresh = React.useCallback(() => {
setRefresh(true);
refetch().then(() => setRefresh(false));
}, []);
}, [refetch]);

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion src/screens/feed/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const Feed = () => {
let onRefresh = React.useCallback(() => {
setRefresh(true);
refetch().then(() => setRefresh(false));
}, []);
}, [refetch]);

return (
<View>
Expand Down
8 changes: 4 additions & 4 deletions src/screens/profile/profile-snaps-view.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useNavigation } from '@react-navigation/native';
import axios from 'axios';
import React, { useState } from 'react';
import React from 'react';
import { FlatList, RefreshControl } from 'react-native'; // Import FlatList

import type { Snap } from '@/api';
Expand All @@ -24,7 +24,7 @@ const ProfileSnapsView = ({ user }: { user: UserType | undefined }) => {
});

// State to track the number of items to render
const [renderCount, setRenderCount] = useState(INITIAL_RENDER);
const [renderCount, setRenderCount] = React.useState(INITIAL_RENDER);

const client = axios.create({
baseURL: BASE_INTERACTION_URL,
Expand Down Expand Up @@ -66,12 +66,12 @@ const ProfileSnapsView = ({ user }: { user: UserType | undefined }) => {
);
}

const [refresh, setRefresh] = useState(false);
const [refresh, setRefresh] = React.useState(false);

let onRefresh = React.useCallback(() => {
setRefresh(true);
refetch().then(() => setRefresh(false));
}, []);
}, [refetch]);

return (
<>
Expand Down

0 comments on commit cf50fce

Please sign in to comment.