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

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -