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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -