Hook Questions
Ad
is it possible in React useState(<></>) has initial state is empty div or component?
My code is like that const [component, setcomponent ] = usestate( ? ) what will be the initial value for
How can I chain functions together in React
I'd like to chain the two functions used below together to improve the experience of our mobile users. first the updateselectedvalue
Concatenate text from React Hook
I have following hook: const [texttofront, settexttofront] = usestate(''); when i call
Modify a React hook variable inside useEffect() that uses a fetch() call
Inside useeffect(), i am requesting data from a server using a fetch() call. upon receipt of the data i am attempting to modify a hook i
how to create state array react hooks on declaration
How do i create a state array with react hooks? i am passing a type i used this method but it's showing me lint error. i also want to know it's
how can I know whether render reason is property changed or state changed in react hook function?
I have a displayer component implemented by react hook. the displayer component receives a set of records by property named 'rows'. it has two
Accessing Refs in React Functional Component
Im using this package to add credit cards to
How to add event listener to a ref?
How can i add an event listener to the ref using reactjs hooks (version 16.8. +)? here is an example where
Re-rendering React component when I call useState hook
I have a problem with the re-rendering react component when i call usestate() hook inside image.onload(). i'm expecting
Why does React tell me that my Material Select input doesn't have a name?
I'm creating a new form with react and one of the inputs is a material ui input. the form works great, but the console shows a missing name
Ad
Problem with state update in function handle
Everybody, i currently have the problem that the state in a handler function is not updated. i have already tried to solve the problem
How to use react-hook-form with ant design or material UI
I'm trying to use react-hook-form library to validate a form. when i render view using ant design or material ui, it does not work correctly.
Parse Nested JSON Using Axios and Async/Await
I am trying to fetch data from an api which should return a json object with an array of recipes. i am using react hooks on the front end and
Prevent Input field to lose focus
Here is an example of code with an input field that is inserted as a component, each change in the input field loses focus. it seems that when you
How to change the state hook with nested objects?
I'm trying to update my state, i have the following one: const [values, setvalues] = usestate({ examplevalue: 280.0 });
How can i redirect after submit form React
I'm newbie for react maybe for english too. how can i redirect after form submitted ? function test() { const { register,
How to use useState hook in React correctly?
I am a little bit confused with using usestate() hook in react. i want to store some data in component state, for example values from form - name,
useEffect show a warning if I call a function in throw props?
I'm using hook in react and i see this warning in my console, i search google but did not find best solution can any one tell me why this warning
Customized Hook with Observer not Rendering
React published a nice custom hook example
How to update state inside a hook and read it from another
I have this react stateless component, the first useeffect should run after the component loads, the second one when i scroll the page, to
React useState hooks error: Argument of type 'xxx' is not assignable to parameter of type 'SetStateAction<xx>'
I use react hooks to update, but notice error when setstate. argument of type '{ alertrules: any; }' is not assignable to
Ad
Reacts useEffects exhaustive deps only trigger to create component will unmount functionality
I am trying to implement a useeffect callback to dispatch an action before unmounting a component. the point of this action is to store the last
State variable is not updated in onClickHandler while using Hooks for getting data from an API by a user input in react
Import react, { usestate } from "react"; export default function empinfo() { const [url, seturl] = usestate(
Issues building pywinhook from source
Python interpreter: 3.7 python library: pywinhook
Child component not rerendering when state change is triggered by its sibling
There are two child components (l1 and l2). both render text and a button. when the button in l1 gets pressed it changes the text of l1 (works
Put Link into json using hook (React)
I have a question, i want to add this command line: cell: ({ row }) => <a
React Context doesn't render component
I'm using context and react router. when i created my context and wrapped my components, nothing rendered. when i check the console, i can see the
Why this problem happend in my react function?
I'm trying to get information from redux but this error happen and i dont know how could i fix it. that's my first time with react and react
Providing data through a HOC but when calling component Property '' is missing in type '{}' but required in type '' error appears
I have the following hoc component providing firebase to my component: import react from 'react' const firebasecontext =
Skip first useEffect render custom hook
I want to make custom hook that will skip first useeffect render and reuse it everywhere. i made a working example of custom hook:
How to mock React setState for API test
I have built a react component api that i would like to test. the api is independent of the react usestate hook for testing purposes. as such, my
Lifecycle issue using React Hooks
My user state const [user, setuser] = usestate({}); fetch function
Ad
React effect infinite re-renders when fetching data
I want to fetch an array from the backend using a provider, context and useeffect: import react, {usestate, useeffect} from
useEffect spamming requests
State const [user, setuser] = usestate({}); checkifuserisenabled()
Update state with dynamically constructed object using reducers in React
I have an array of values which are set in state to a boolean. i need to loop through the array and set each value to the payload (true). the code
Stop hooks re-fetching data on component update
I am new to react hooks and as i read in docs useeffect runs on every update of component and on first render also (so it is
React Hook useEffect has a missing dependency: 'dispatch'
This is my first time working with react js , im trying to remove the alert when leaving this view cause i don't want to show it on the other view
react hooks, cant updating state via props
Trying to update state variable('visible') via internal function(setvisible) in component. i checked the
How to structure a component using React Hooks with an object that uses the DOM directly? (such as OpenLayers)?)
I'm trying out using react hooks where in a component that i previously have as class based. the component looks like this: class
Argument of type 'State' is not assignable to parameter of type 'never'
I have just started using typescript with react. i tried using it with react usereducer hook but i am stuck because of a weird error. here
how to call 2 times when data in graphql react?
Loadgreeting () is not caused by another time when changes props.currentstore const [loadgreeting, { called, loading, data }] =
In useEffect, what's the difference between providing no dependency array and an empty one?
I gather that the useeffect hook is run after every render, if provided with an empty dependency array:
How to prevent useless update requests in `useEffect` without using additional variables
I want to do this useeffect(() => { if (!datasetsstate.list.length) { dispatch({ type: datasetsactiontypes.fetch,
Ad
Adding new object in array in existing array
I have a crud functionality in my react application using hooks and es6. i'm using antdesign list component as well. in my add function, after
React: incorrect examples of calling Hooks inside loops and nested functions
The first rule of hooks is to only call hooks at the top level, i.e. "don’t call hooks inside loops, conditions, or nested functions". the docs
React useEffect hook infinity loop
I keep encountering an infinity loop when trying to use the useeffect hook to fetch and set data. ive tried 3 variations of the hook and they all
React useEffect (with []) is called every time I change page (React Router)
I prepared small demo for the problem:
Lazy initial state - What it is and how to use it?
I am new to react hooks. am trying to make use of usestate in my code. while i was using it i found a term "lazy initial
useApi hook with multiple parameters
I have a useapi custom hook, that takes an endpoint (url) with multiple parameters. when one of the parameters changes a graph is rendered. the
How do you use the result of a graphql query as a return value in a react functional component?
I'm new to react, and i'm querying the graphql endpoint and sending it a json object. i have a file called service.jsx with a functional component
Preventing rerenders when using object as state in useState
Background: i am rendering a dynamic list of collapsible elements. the open/close state of the collapse is stored in a
React Hooks: what is the correct way to handle async setState inside component ? (uploadProgress axios)
We want to post multiple files in parallel and display upload progress. our first attempt to solve it was to use setstate and the previous
Why `Invalid hook call` Error Show when i implemented useState inn react
I am trying to implement usestate in react and i am getting erroe invalid hook call. hooks can only be called inside of the
map function on React state - state with fetched API data
Import movie from './movie'; import axios from 'axios'; import yargsparser from 'yargs-parser'; function app() { const [isloading,
Ad
React functional component state change does not trigger child component to re-read its props
I'm having this react functional component. we know that since v16.8, functional component has kind of "state". it uses useeffect to "setstate" to
Incorrect dependency behavior in hook useEffect?
I've got a problem with infinite loop inside useeffect. i want to make new request only when id dependency changes. when i not pass
Does clearing timeout/interval have to be inside `useEffect` react hook?
I'm wondering what is the correct way and best practice to clear timeouts/intervals when using react hooks. for example i have the following
React Hooks, prop value changing randomly between renders
I'm trying to convert a class component, which is a gatsby layout component, to a functional component using react hooks to manage state. my goal
Infinite loop in useEffect when setting state
I've got a question about useeffect and usestate inside of it. i am building a component: const [id,
React hook useState with array cause missing render calls
I have following code: function mycomponent( props ) { let arrsize = 5; const [arr, setarr] = usestate( () => {
React hooks using recharts AreaChart Console Warning
I implemented areachart from recharts on my app like this: import react from 'react'; import { areachart, area, xaxis,
useState does not rerender unless I copy the array
In a react-native project i'm using react-native-camera-roll-picker. the idea is that a user selects an image and the header changes
How do I define the type that the useState hook is expecting if I want to store an array of objects?
I am trying to store an array of objects using the usestate hook but cannot get the syntax for describing the type it is expecting.
Destructuring an object in TS
I have this ts code, and i want to make that part to be also typed : const { data: { person, car, another } }: any =
Array split React Hooks
I want to split an array into two arrays. the problem is main array which i want to split into two is coming from server.and i need to
Ad
useState object set
I am new to reactjs and working with hooks. i want to set state for object. here is my code: const startpage = (props)=> {
Component wont re-render when changes happens to redux store
I have problems with using redux saga with react hooks. it clearly states that useselector() will subscribe to the redux store, and run the
Type inference of function as argument in Typescript
I have case as shown in images below - my function accepts options in form of object with one of arguments being transform function.
Using comparison in useEffect's dependency array
I'm creating a search input with a submit button and a clear button. when submit button is clicked, it will trigger a search request with
Adding an object to an array (with Hooks in React)
I want to add an object to an array in react using hooks, i'm doing a chat, and i want to add a new message to the array of messages, i
React hooks and functional component ref
Const comp1 = forwardref((props, ref) => { useimperativehandle(ref, () => ({ print: () => { console.log('comp1')
When I use value in input , I can't type a text in input
When i want use value={templogin.login} i can't type in my input . what did i do wrong ? i don't see mistakes in event,object and
React looping hooks to display in other hook
I'm working on a react web app, and i'm trying to loop a list of objects and output the content to another hook, see below for details.
React Apollo Client - modify query data before it goes to cache
Is there a way to modify query response data before it is saved in the internal cache? i'm using apollo hooks, but this question is relevant to
onChange method is not working on all the fields
I've defined the initial value for the input fields in usestate hook, here is the code: const [name, setname] =
How to wait for multiple state updates in multiple hooks?
Example in my scenario i have a sidebar with filters.. each filter is created by a hook: const filters =
Ad
How to store refs in functional component properly
I'm trying to create a component that tests english vocabulary. basically, there are 4 options with 1 correct. when user chooses option,
Hooks API - Avoid state overwrite when setting state after await statement
Let's say we have a tile grid with the follow behavior: there's a button for adding a tile. the tile will decide if it should be a
Hooks error: Invalid Hook Call using NextJS or ReactJS on Windows
While attempting to use react hooks in nextjs i continue to receive the following error: hooks can only be called inside
Git submodule update from post-receive hook
I'm trying to update automatically my submodule located in var/www/php/vendor/projectx at each commit to the var/www
Flow js doesn`t apply generic
I have a function (react hook): function usehandles<tpreparedvalues, tvalues>({ onreject, makedata, }:
Dynamic import of react hooks
Can we dynamically import hooks based on the value passed to the component? for eg. app.js <basecomponent
Use React-Hook with redirect and setTimeout
I have a modal displayed after a register user and i would like it to disappear after a few seconds with a redirect as i write above i use
Cannot use array methods on array of objects
I cannot use array methods on an array of objects. the shellsarray logs out (6) [{…}, {…}, {…}, {…}, {…}, {…}] in the
How to use the getFieldDecorator with react (function) hooks
I am trying to create a simple antd form but dont know how to make the getfielddecorator to work with my react function. how do i translate
How to change React-Hook-Form defaultValue with useEffect()?
I am creating a page for user to update personal data with react-hook-form. once paged is loaded, i use useeffect to fetch the user's
Add listener for all element events in WPF
I would like to hook for all available element events in one call. some thing like this: elem.addhandler(anyroutedevent,
Ad
What is the difference between using setItem to set multiple state values and using useEffect to do so?
I have a reset button in my app that resets a few variables of my functional component: const [selecteditem, setselecteditem] =
How to get extra properties from selected item using React DropdownButton
I'm a java developer working on a react prototype and stuck trying to retrieve the id property from the selected dropdown item, which we then
How to show/hide a button only in one object in an array of object?
I am using an array of objects to loop some services in my webpage. the data is data.js
Why can't access my new state value from another function in react.js hook?
I set my marinalist new value. i can access marinalist state in getmarinalist function. but when i try access marinalist state in
How can I make a button link to another component?
I am attempting to load my register component when a button is clicked in my login component using usenavigate hook but when i add
React focus useRef only working on refresh
I am using a <navlink /> to direct navigation to a specific component. i am thinking this is the problem - but the problem
update package.json version automatically
Before i do a small release and tag it, i'd like to update the package.json to reflect the new version of the program. is there a way to
React useEffect function deps keep looping
I have this code // snackbar.js import { isstring } from 'lodash'; import { usecallback, usememo, usestate } from 'react'; import
How do I implement the Post Commit Hook with Trac & SVN in a Windows Environment?
I'm running in a windows environment with trac / svn and i want commits to the repository to integrate to trac and close the bugs that were noted
How to define time out to API petition using axios reactjs
I am trying to set timeout to api petition in case i get some error using get, then loader keeps running for at least 3 seconds to
How can I re-trigger a custom hook inside my react component, when its states have not changed?
I have a custom hook for fetching data from the server. it takes 3 parameters, which are pagenumber, pagesize, and keyword. i understand if i set
Ad
displaying array data in react. output is not coming
When i am printing console.log(response.data) in console below output is coming.
Data created with form onSubmit is not saved correctly (React Hooks and JSON)
I have a form that it needs to create the item "post" with a unique id, title, author and content. something like this: {
Ad
Blog Categories
Ad