score:0
i don't see any issue in the shared code but i can point 1 area which might be causing problem for you.
i guess it's the moment()
which returns a date object. i am not sure whats the appointment format you have in props
, so if you can share these details then probably i can share the whole code or just give it a try, it shouldn't be that complex.
i have created a demo without moment
, which works fine.
https://codesandbox.io/s/serene-davinci-quxz1?fontsize=14&hidenavigation=1&theme=dark
also instead of directly putting the function in usestate
, try this
const initialnextappointment = getnextappointment(appointments);
var [nextappointment, setnextappointment] = react.usestate(
initialnextappointment
);
let me know if this helps!
Source: stackoverflow.com
Related Query
- Why is my initial state value in useState undefined?
- How to set initial state value for useState Hook in jest and enzyme?
- react: Initial state value is undefined
- useState hook - state gets lost i.e. resets to initial value
- How to set the initial value of useState with the value of another state set in a useEffect hook?
- Functional component as initial state value throws children undefined without wrapping in React.memo
- Undefined value for initial state in ReactJS
- React: Why is my state undefined on the initial render from useEffect?
- How to type the initial state for react context when using useState as value
- Why cant I take a value from the current state and use that inside of my useState hook?
- ReactJS: Why is passing the component initial state a prop an anti-pattern?
- React useState hook event handler using initial state
- How to set initial state for useState Hook in jest and enzyme?
- React - useState not setting initial value
- React - useState - why setTimeout function does not have latest state value?
- When to use useState initial value as function?
- console log the state after using useState doesn't return the current value
- useState hook, setState function. Accessing previous state value
- React w/ TypeScript: why is the type for the state lost when useState with a callback as the updater
- Why does the 'useState' hook invoke the initial state when it's a function reference?
- Why is state undefined when passed through React Router Link Component?
- Why doesn't useState function initialize state every time?
- useState hook can only set one object at the time and return the other object of the same array to initial state
- Redux state props value is undefined
- Why does calling useState's setter with the same value subsequently trigger a component update even if the old state equals the new state?
- how can we use redux state in useState to set initial values
- Why cant react set initial state based on props
- Use useState value in useEffect without making the state update useEffect
- Why is useState hook calling initialising value code twice?
- Why the initial value of the hooks cannot be given an empty object?
More Query from same tag
- When the form is empty, pressing the Login button opens the page. I have to make a mistake
- How can I change the color of the ANT Design's Spin component?
- react-redux TypeError: notes.map is not a function
- Handle children.props
- how to remove event listener from document in reactjs
- How to handle click row event on react-table
- React: Can't call prop function when it is inside of another function?
- HTML rendering on server with Node.js
- React Router v4 - Dynamic Nested Paths
- React Error : __WEBPACK_IMPORTED_MODULE_4_jquery___default(...)(...).modal is not a function
- How to test functions inside functional components with React hooks?
- How to set zoom control option?
- How to keep CSS Attributes specific to each page in a SPA build on Reactjs, when css is applied on body or html
- Antd React - How can i check all tree nodes with a select all checkbox?
- ReactJS - get latitude on click and show it in input
- Difference and use cases with useEffect and useMemo hooks on React
- Firebase read with react useeffect async not waiting for document read
- React Testing Library does not find elements using getAllByTestId after initial render
- Importing FontAwesome icons by string array in React.js
- how to fix application error on heroku when i deploy react app along with json-server
- Material-UI withStyles doesn't apply any kind of styles
- How can I get more than one document from mongoDB?
- when we enter the username in login page, Home page should display Welcome {username} , how to show this using react js
- Update non state variable in React useEffect
- Can I manually override google optimize redirect, and avoid external redirect?
- Stop statically served React app from calling server path
- How to test a custom hook event with Enzyme and Jest? (useKeyPress)
- How can I remove a chip from a controlled autocomplete?
- How do I connect my discriminators in mongoose to my parent document? Getting errors when trying to import data
- React hover/active/focus style css selector not working for enclosed element