Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
Inject multiple stores to scenes with Asp.net Boilerplate

Which is the correct way of injecting multiple stores into a scene? I couldn't find any example about this. Everyone injects just one store into a scene. Is there a rule or concept in Asp.net boilerplate about using stores with mobx-react?

İnjecting to component

import RefineryStore from '../../stores/refineryStore';
import Stores from '../../stores/storeIdentifier';
import UserStore from '../../stores/userStore';

export interface IRefineryProps {
    refineryStore: RefineryStore;
    userStore: UserStore;
}

@inject(Stores.RefineryStore, Stores.UserStore) // Why noone adds two stores into one inject?
@observer
class Refineries extends AppComponentBase<IRefineryProps, IRefineryState> {
   public render() {
        const { refineries } = this.props.refineryStore;
        const { managers } = this.props.userStore;
        return ()
  }
}

Defining Stores class

export default class Stores {
  static AuthenticationStore: string = 'authenticationStore';
  static RoleStore: string = 'roleStore';
  static TenantStore: string = 'tenantStore';
  static UserStore: string = 'userStore';
  static SessionStore: string = 'sessionStore';
  static AccountStore: string = 'accountStore';
  static RefineryStore: string = 'refineryStore';
}

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It is totally fine to inject several stores if you need them. You can even have RootStore which combines everything and inject every store in every component, for example.

The modern approach would be to use hooks as described in this docs

With that way your components would look much simpler:

const Refineries = observer(() => {
  const { refineryStore, userStore } = useStores()

  return (
    <div>
      ...
    </div>
  )
})

Although it would require you to use functional components instead of class, so you still might want to stick to inject if you have big legacy app and not much time for refactoring.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!