score:0
Accepted answer
you interface defines itemid?: string;
and a string or undefined but the function call needs a string.
use either
if (itemid) {
toggledrawing(itemid);
}
or
toggledrawing(itemid || '');
or
toggledrawing(itemid as string);
score:1
try this way ;)
const toggledrawing = react.usecallback(async (itemid: string | undefined) => {
if (isdrawing && editableitemid === itemid) {
canceldrawing();
} else if (isdrawing) {
canceldrawing();
seteditableitemid(itemid);
} else {
seteditableworkareaid(itemid);
}
},[])
Source: stackoverflow.com
Related Query
- How to fix the error argument of type string or undefined is not assignable to parameter of type string using typescript and react?
- How to fix error argument of type undefined is not assignable to parameter of type 'string or () => string usng typescript and react?
- How to fix the error type Item[] | undefined is not assignable to Item[] type using react and typescript?
- How to fix the type error Type '(string | Element) [] is not assignable to type 'string | Element | undefined' using react and typescript?
- How to fix the error argument of type boolean or undefined using react and typescript?
- How to fix the Argument of type 'Date[]' is not assignable to parameter of type '(prevState: undefined) in react
- How to fix the error type void is not assignable to type ((event: MouseEvent<HTMLDivElement, MouseEvent>) => void) |undefined using react?
- How do I fix a React TypeScript error with the return value of useHotkeys hook not matching the type of the div element ref prop
- How to solve the error 'Warning: React.createElement: type should not be null, undefined in React?
- How to fix error type void is not assignable to type using react and typescript?
- Why does TS give the following error in my case: Argument of type 'number' is not assignable to parameter of type 'never'?
- TypeScript Error (TS2345) argument of type Person | undefined is not assignable to paramater of type Person
- How to fix argument of type is is not assignable to parameter of type
- How to fix React TypeScript error: Argument of type '""' is not assignable to parameter of type 'SetStateAction<undefined>'
- How to fix the date[] is not assignable to type [date?, date?] in react hook
- How to fix error "argument of type false is not assignable to (currentValue: boolean) => boolean" using react and typescript?
- How to fix error "argument of type (open: any) => boolean is not assignable to parameter of type boolean" using react and typescript?
- How to fix the error is not assignable to InstrinsicAttributes in react?
- getting error : Argument of type '() => () => boolean' is not assignable to parameter of type 'EffectCallback'
- Trying to deploy my React app with gh-pages but got this error message : The "file" argument must be of type string. Received type undefined
- How to fix the error 'alpha' is not exported from '@material-ui/core/styles' when using Skeleton in Material UI
- Argument of type 'string | null' is not assignable to parameter of type 'ValueFn<SVGPathElement, Datum[], string | number | boolean | null>'
- Getting an error Argument of type 'unknown' is not assignable to parameter of type 'Error | null'
- How to fix the error TypeError: Cannot read property 'map' of undefined
- How to fix Type not assignable to LibraryManagedAttributes for react router render prop
- How to fix the error "Property contains doesnt exist on type 'RefObject' using typescript and react?
- Using state and includes in React gives Argument of type 'number' is not assignable to parameter of type 'never' error
- How to fix Uncaught TypeError: Object(...) is not a function error when I connect Redux to the project
- Error argument of type 'Item' is not assignable to parameter of type 'string'. TS2345
- How do I fix the error "Element implicitly has an 'any' type because the expression of type
More Query from same tag
- How to use selectedOption in react-select
- removeEventListener for window.onstorage?
- How do I map dates with a specific ID in textfield value?
- Need help getting 1 line covered with Jest (React)
- Burger menu using bulma on React not working
- material ui app bar not showing - reactjs
- jump to specific time in videojs using react hooks
- Set base path for all the images in by react app
- Redux Form v6 - Generating dynamic form with unique keys loses focus on entering value
- Redux Form Typescript Pass Custom Props
- Passing a Prop in an On Click Function in React/Redux
- Is there a way to change a bootstrap react card component's border size?
- Prevent onmouseout from firing on child elements
- Deployed a website in React using Netlify, but I get a blank page
- getElementById in React
- PWA update icon after user add to homescreen
- How to create buttons that will show / hide the state of all detail tags in a Docusaurus project?
- React: Ref DOM Elements/Nodes are printing different information from the actual Ref DOM?
- React document.removeEventListener is not working
- Integrating web3 from Metamask in React
- React can't set state
- Getting undefined behaviour while using functional components?
- Update useContext using response from axios
- Having a Fullscreen preview image onHover property in Mapbox GL to cover entire map
- Phone format in React
- React componentDidMount - Cannot read property of undefined -
- Can't access data in my redux store react
- Render a loader while files are sent to the server in react.js
- I can't call the modal component in other component correctly on React
- React-Redux, when dispatching a function, "uncaught TypeError is not a function"