score:2
Accepted answer
it seems like you are trying to use react functional components, as you are using the usestate hook.
in that case, you should not be creating a class and extending it from react.component
, as those are for defining class components.
this is how you can define functional components using react and typescript.
interface initialstateprops {
eventinfo: {
name: string;
location: string;
}
}
const dashboard: react.fc = () => {
const [formvalues, setformvalues] = usestate<initialstateprops>({
eventinfo: {
name: '',
location: ''
}
})
return <div></div>
};
Source: stackoverflow.com
Related Query
- Why typescript throw error at useState react
- Why does react hook throw the act error when used with fetch api?
- Why do semicolons throw error in react JSX?
- Why does React throw an error when setState method used in a class constructor?
- Typescript error when use react useState hook with generics
- TypeScript 1.8 - Why does my React Stateless Function component throw a TypeError at runtime?
- typescript spread operator for props in react throw error
- Typescript error on react useState hook when updating typescript version
- Typescript error showing up when update method for state element by using React useState
- Getting Typescript Error while adding object to array using useState in React
- TypeScript Error in React component on useState declaration and passing props to child component
- Why react hook usestate show an error message
- Why does Typescript throw an error when typing Redux-saga call parameter - TS2339
- Why does the React hook useRef throw an error when used?
- Typescript useState React Hook Destructuring Error (Not Returning Array?)
- Why `Invalid hook call` Error Show when i implemented useState inn react
- Set types on useState React Hook with TypeScript
- Cannot find namespace 'ctx' error when creating Context with react - typescript
- Why React Hook useState uses const and not let
- Why React useState with functional update form is needed?
- React - useState - why setTimeout function does not have latest state value?
- React hooks: Why do several useState setters in an async function cause several rerenders?
- Typescript React <Select> onChange handler type error
- Why does my React Native app build successfully despite TypeScript compiler error?
- react/prop-types eslint error in typescript react component
- Why I got Error while Creating React App?
- Typescript error during inline fontWeight style in React
- React Typescript hook error - This expression is not callable
- React typescript error Parsing error: '>' expected
- React w/ TypeScript: why is the type for the state lost when useState with a callback as the updater
More Query from same tag
- Why NextJS using Docker container did not reload after changed code for dev environment?
- this.props.fetch is not a function redux
- React Bootstrap - 'openModal' is not defined no-undef
- Is there a way to use my styles as an external css file in react?
- React pass state to nested components not working
- Add multiple value in array
- How can I test if a blur event happen in onClick event handler?
- How to get checked State in functional child component
- Data from getServerSideProps not showing
- How to call Promise.all in a handler function in React.js
- MUI Select label not hiding properly
- How do I generate dynamic meta description and image in React using React Helmet?
- React-admin: Unable to import Json data from Nodejs
- How do I create a user using a post request in react-chat-engine?
- Using connect() with React/Redux/TypeScript cannot find property
- I want to set the thumbnail to an image tag retrieved from GraphQL. However, a string is displayed
- React checkbox group is not being updated with the state
- How can I customize the mui circularprogress bar?
- State is undefined
- Webpack - npm run start and build doesn't work?
- Component as Pop up Content
- How to render formatted text in ReactJS webapp?
- add item to async array with splice and useState
- Form created with React doesn't update the backing state object
- Apply styled component style to a third party components
- Mapping over nested objects
- React: error when integrate component without JSX
- Material UI Autocomplete add item with multiple select
- How to make Icon fit in Menu.Item in Semantic UI React Vertical Menu?
- Do I have to use bind(this) in this method?