@redeemedrobert wrote:
I’m trying to drill app state down through component props in app.tsx, but get a typescript error:
Type '{ dailyObd: RouteComponentProps<any, StaticContext, {}>; }' is not assignable to type 'IntrinsicAttributes & obds & { children?: ReactNode; }'. Property 'dailyObd' does not exist on type 'IntrinsicAttributes & obds & { children?: ReactNode; }'.ts(2322)
Here’s a breakdown of what I’ve got:
app.tsx:const App: React.FC = () => { const [dailyObds, setDailyObds] = useState<dailyObds>([{ title: 'First', completed: false }]) return ( <IonApp> <IonReactRouter> <IonSplitPane contentId="main"> <Menu /> <IonRouterOutlet id="main"> <Route path="/page/today" render={(dailyObds)=>(<Today dailyObd={dailyObds} /> )} /> <Redirect from="/" to="/page/Inbox" exact /> </IonRouterOutlet> </IonSplitPane> </IonReactRouter> </IonApp> ) } interface dailyObd{ title: string completed: boolean } interface dailyObds extends Array<dailyObd>{} export default App;
Here’s Today.tsx:
const Today: React.FC = ({ dailyObd })=>{ return ( <IonPage> <IonHeader> <IonToolbar> <IonButtons slot="start"><IonMenuButton /></IonButtons> <IonTitle>Today</IonTitle> </IonToolbar> </IonHeader> <IonContent> <IonText>Some stuff will go here... eventually.</IonText>> </IonContent> </IonPage> ) }
I set strict to false in tsconfig.json, but I still can’t compile because of the listed error. What am I missing here? Why is it seemingly so difficult to add a prop to a component with TypeScript? Thanks for any help, I am new to Ionic/React/TypeScript.
Posts: 1
Participants: 1