Category "react-hooks"

Avoid runnning an effect hook when Context get updated

I have a component MyContainer which has a state variable (defined via useState hook), defines a context provider to which it passes the state variable as value

Is there a library similar to Vueuse but for React?

Instead of having many dependencies for individual hooks, I am interested in a single curated and tested library like Vueuse, but for React. Does something like

Why can't `useCallback` always return the same ref

I don't understand why useCallback always returns a new ref each time one of the deps is updated. It results in many re-render that React.memo() could have avoi

Why can't `useCallback` always return the same ref

I don't understand why useCallback always returns a new ref each time one of the deps is updated. It results in many re-render that React.memo() could have avoi

Displaying data from Firestore into React Native FlatList did not work

I'm using the React Native FlatList module to show data that is stored in an firestore collection. This data should rendered into an content box with an colored

State Not Updating when Consuming React Custom Hook that Uses Axios with useReducer to Get Async Data

My app returns a "null is not an object" Render Error when consuming the useFetch custom hook that I made to get async data using axios. The status, error, and

How to call a function every minute in a React component?

I make a table to get stock price quotes, it works well, but when I try to put a function include setState in the component, it falls into an infinite loop, it

Custom React Hook typescript error on array return type

I've created a very simple custom hook: export function useI18n() : [ string, Dispatch<SetStateAction<string>> ] { const [ language, setLanguage

Custom React Hook typescript error on array return type

I've created a very simple custom hook: export function useI18n() : [ string, Dispatch<SetStateAction<string>> ] { const [ language, setLanguage

useState and if statement causing Error: Too many re-renders. React limits the number of renders to prevent an infinite loop

What I'm attempting to create is a React component which conditionally renders when the value of the prop boxToggle is true, and also returns null when the user

react route component is not rendering anything

I created my app with create-react-app and tried to use react-router on it. but it's not working at all. I am using react-router-dom 5.3.0 version. But if I typ

Cannot position react-perfect-scrollbar with scrollTop using React hooks

I have an array of objects being rendered in a table with a react-perfect-scrollbar instance. The code is the following: const myComponent = ({ myArray }) =>

Unsubscribe from watchPositionAsync with useEffect return function

Using react native with expo-location for a mobile app, I would like to unsubscribe from Location.watchPositionAsync which returns a promise with a remove() met

React Hooks with Redux & MVVM architecture

I am trying to update my React application to use MVVM as an architecture pattern. I initially built it out with Hooks and Redux. I've come to find out that eve

First Character is not displaying in input field useForms

When I click on Submit, it gives an error "required". But when i type text it doesn't take first character. On entering first character it only removes "require

React Hooks with Redux & MVVM architecture

I am trying to update my React application to use MVVM as an architecture pattern. I initially built it out with Hooks and Redux. I've come to find out that eve

Adding a key-value pair to an object inside loop using React useState hook

I'm trying to add a key-value pair to an object using useState inside map function. However, the spread operation in setContainer({...container, [data.pk]: data

React-chartjs-2 update height dynamically

I am using react-chartjs-2 library. I have used HorizantalBar which will receive data through props dynamically from parent component. I have wrapped Horizantal

How to implement Twak.to widget in a Next JS website?

I have tried what is written on their @tawk.to/tawk-messenger-react plugin docs? I have made a component like /components/Chat.js import TawkMessengerReact from

React-typescript: Object is of type 'unknown'. TS2571

I am using React-TypeScript for my project. For state management, I am using React-redux, for function handling I am using redux-saga. For gluing the redux stor