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

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -