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

188
Views
Why do we have interfaces and initialstates in React and typescript for Redux tool kit?

I am learning how to use typescript with react and I am new to all those technologies.

In the example below why do we write the codes like that; I am studying from a code base and the Redux tool kit has been used and the logic is written in this way as below: why do we have interfaces and initial states separately? I know that I am missing a lot of basic. Thank you for your help.

export interface ProjectState {
  projectId: number | undefined;
  project: Project | undefined;
  projectInfo: ProjectInfo | undefined;
  fields: Array<Field> | undefined;

const initialState: ProjectState = {
  projectId: undefined,
  project: undefined,
  projectInfo: undefined,
  fields: undefined,
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

first is good to recall the basics, an interface in typescript is like a contract within an object and the shape it should implement. So another thing is you can't create an instance of an interface, you will never see something like this.

export interface ProjectState {
 ...
}

const project = new ProjectState;

This is why you are watching the initial state and the interface separately. The principal reason why the people prefer to create an interface insted of using type, is to export it and re-use the same contract in others part of the application.

Keep in you learning process, you are doing great!

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!