The expected type comes from property ‘ ‘ which is declared here on type ‘IntrinsicAttributes & ‘–prop’
I am trying to pass data from Parent to Child (dialog) component but it considering it as null . The data is coming from api and rendering in the parent component based on id, same data is to be displayed on the form in the dialog when edit button is clicked. It is showing error in Parent
Type ‘null’ is not assignable to type ‘{ id: number; name: string; email: string; } | undefined’.ts(2322)
dialogBox.tsx(13, 3): The expected type comes from property ‘postData’ which is declared here on type ‘IntrinsicAttributes & DialogProps’
and in Dialog this error ‘postData’ is possibly ‘undefined’.ts(18048)
Parents
Prepopulate Dialog Form with Data from Parent in React(Typescript)
Using Reactjs and Typescript, I have a parent component with data from api. It clicks to open a MUI Dialog with a form to edit but needs to be prepopulated with the data from the parents component. The parent gets its data from an api.Its is not getting the data in the textfield of the dialog and giving error for ‘PostData.email’ in the child component.
**’PostData’ is possibly ‘undefined’.ts(18048)