Category "react-hooks"

why can't i use useState in react

When I want to use useState, one of the hooks structures, in react, he gets angry with me const [apple, setApple] = useState(false). I have never encountered su

Material-UI-Search Bar value not clearing

I am using the @material-ui-searchbar to filter data. I'm using the same container for multiple different pages to display the info. When ever I switch between

Memoized functions to custom hook not picking up updated value from hook

Given a small hook defined as const useCount = ({ trigger }) => { const [count, setCount] = useState(1) const increment = () => setCount(count => c

Is it recommended to pass setters from useState as props?

I am currently in a coding bootcamp and the instructor told me that it is not best practice to pass the setters defined in my useState as props to children comp

How can I run React with hooks in an iFrame

I am writing a React application in which I would like to dynamically render React components through an iFrame. I have a code editor on the webpage that allows

How to re-render react-table in .js when data changes in another .js

I am new to react-table and trying to re-render a react-table when data supplied to it changes. Is there anyway to do so? I have tried using useEffect() with no

A problem that i am having making conway's game of life in react (nextjs). when i press the Random button while it is running, it starts flickering

Here is a the code for you to try. both button works fine while the game is paused or running very fast, but if i set the timeout above 100 or 200 ms and the ga

A problem that i am having making conway's game of life in react (nextjs). when i press the Random button while it is running, it starts flickering

Here is a the code for you to try. both button works fine while the game is paused or running very fast, but if i set the timeout above 100 or 200 ms and the ga

Target map()'ed items one by one

I want to create a contact form where the form fields are changed after they are filled. For example when you fill the email field, you press enter or click the

How can I render only once an Alert component in react native?

How can I render only one time an Alert component in react native if my dashboardScreen is being render many times? I'm using Context api, if I dispatch an acti

React hooks: Why do several useState setters in an async function cause several rerenders?

This following onClick callback function will cause 1 re-render: const handleClickSync = () => { // Order of setters doesn't matter - React lumps all state

Make hooks stop randomizing background color

So I wanted to use hooks for an exercise where I have a circle follow my cursor in React ( and then see other users circles using node) so I've set a randomColo

React Dev Tools: "parse hook names" action throws a "Hook parsing failed" error

When I inspect my code using the react devtools, I'm noticing some hooks trigger this error and cause the "parse hook names" action to error out. When I inspect

Can I change the state for given time and then revert it back to the original state using settimeout

I want to get the value to true for one second, after which it will revert back to false using settimeout but stuck. Here is my code: const [value, setValue] =

How do I save responses from an API to a state so that I can display old searches/responses?

Here's what I'm trying to do: First, I want to display the response I receive from the API (I can do that), but then I want to display the previous prompts and

next-auth only valid absolute URLs can be requested

I updated [email protected] to [email protected] for okta signin(reactjs). After that I am getting the following errors: [next-auth][error][SIGNIN_OAUTH_ERROR] htt

Next.js router.query getting undefined on refreshing page, but works if you navigate to it from Link component [duplicate]

Why is router.query empty when I refresh a page with the correct id in the URL, but when when I navigate towards it through , it works? say I

UseReducer hook doesn't update state (Can't perform a React state update on an unmounted component)

I'm trying to use useReducer instead of useState in a custom hook that loads the initial data from the API, and getting an error updating a state. (I use useRed

Setting state in React useEffect hook

In my app I fetch data from my API after a button is clicked that changes the state of endpoint. Until the data is fetched I want to display a loading icon. Aft

How can I call Rtk Query Hook when the condition changes?

I created the endpoint with createApi: export const postsApi = createApi({ reducerPath: 'postsApi', baseQuery: fetchBaseQuery({baseUrl: 'https://jsonplaceho