reactjs - How to pass an instance of a service to a react router component in typescript -
we have following code:
//routes.tsx const auth = new authservice(); export default <route component={ layout }> <route path='/login' components={{body:login}} </route>; //layout.tsx export interface layoutprops { body: react.reactelement<any> }
i'd login component have access authentication service instantiated in routes.tsx
the way understand it, have add layoutprops interface can't find type allow instance of authservice passed.
what ended doing was:
export const auth = new authservice()
in authservice file. @ same time not export type.
that way class needed auth service have import instance file , not create instance.
Comments
Post a Comment