score:0
ok, i seem to have figured out a fix:
by creating a
type promptinputcustominput<t> = (value: t, onchange: (newvalue: t) => void) => react.reactnode;
and changing the interface to:
interface promptinput {
key: string,
title: string,
custominput?: promptinputcustominput<any>;
}
and changing where i pass the arguments to:
<inputpromptdialog
inputs={[
{ key: 'fullname', title: 'full name' },
{ key: 'email', title: 'email' },
{ key: 'role', title: 'role', custominput: ((value, onchange) => <roleselector onchange={(selectedroleid: string) => onchange(selectedroleid)} />) as promptinputcustominput<string> },
]}
/>
this creates the desired result i am looking for. but i would still be interested to know if there is a way of doing this without having to always cast the values i am passing as promptinputcustominput<desired_type>
Source: stackoverflow.com
Related Query
- How to implement a generic arrow function as interface property in Typescript with React JSX
- Typescript Can't implement generic function interface
- How to create a generic arrow function with react and typescript
- Type of Generic Stateless Component React? OR Extending generic function interface in typescript to have a further generic?
- How to spy on a class property arrow function using Jest
- how do you pass a generic type to an anonymous function in typescript tsx file
- How to create generic typescript function that binds arguments for storybook control
- TypeScript interface default value when a property is a function type for useContext hooks
- How do you annotate an unnamed arrow function in typescript
- How to add a function in an interface React Typescript
- How to add two arguments using Typescript Generics in Arrow Function
- How to setup a generic interface for the state when using React useReducer with typescript
- How to use typescript interface property with the margin property?
- how do you specify a class function to use typescript props interface
- Typescript property as string, how do I get the interface
- How to correctly type a generic React function component in TypeScript
- Defining React-Redux dispatch as generic function property throws error with typescript 3.1.3
- How to define an TypeScript interface of an function on a react class?
- How to implement an props interface for conditions with styled components in React with Typescript
- How to define a private property when implementing an interface in Typescript?
- React prop types with TypeScript - how to have a function type?
- How to pass a function as an argument to a ReactJS component in TypeScript
- How can I define TypeScript type for a setState function when React.Dispatch<React.SetStateAction<string>> not accepted?
- Typescript declaration merging to expand or override module type or interface property
- How to extend a native's component's props TypeScript interface in a stateless, functional component in React Native?
- How to use jest.spyOn with React function component using Typescript
- How to understand complicated typescript generic types?
- How do you correctly use React.lazy() in Typescript to import a react component with a generic type parameter?
- TypeScript React: How do you pass a generic to a React.ComponentProps<typeof ComponentWithGenericProps>?
- TypeScript - ReactRouter | Arrow function captures the global value of 'this' which implicitly has type 'any'
More Query from same tag
- How to remove underline from font awesome icon
- Alphabetically order with header in reactjs
- Cannot call `this.setState` with object literal bound to `partialState` because string [1] is compatible not with string literal [2]
- React: "Cmd-Click" a button that navigates somewhere. Best Practices?
- how to pass outlet context to nested route in react router v6
- (Solved) React/JS How to get the value of last index of props.data which is an object
- Styling a nested styled-component from an outer one
- Is there a way to have a default search criteria
- Closing a popper MUI using ClickAwayListener affects everything inside
- Configuring React with Asp.net MVC4,getting error like Failed to load resource[app.jsx] in browser
- Function to update object values with different nesting depths
- useReducer: dispatch causes rerender even if state is not changed
- ReactDOM: Uncaught TypeError: Cannot read property 'render' of undefined
- Can you add a button inside a custom TableCell in material UI?
- React Redux Fast Update State
- What is the best way to redirect a page using React Router?
- Why to pass callbacks in React component's props instead of using react-redux's connect?
- useEffect with only one dependency / React Hook useEffect has a missing dependency: 'props'
- The right way to import React
- Equivalent of hooks state callback like setstate
- How to spy on a class property arrow function using Jest
- How to use csrf_token in Django RESTful API and React?
- useDispatch() Error: Could not find react-redux context value; please ensure the component is wrapped in a <Provider>
- Create custom react route component with typescript. Property 'path' does not exist on type... RouteProps
- Only send values that have changed in formik onSubmit
- Cannot able to call funtion/access variable from funtion components
- Passing useState as props in typescript
- How to populate ToDo list with UseEffect Axios API call in React?
- How to get the values for dynamically generated input field in react js?
- React Flask Heroku App is not displaying frontend