0

I'm trying to make my life easier by using type-specific objects in my javascript react project (typescript is unfortunately not an option). This is the code snippet that is causing the issue:

const [projectsList, setProjectsList] = useState<Project>(testProject);

And my model looks like:

export class Project {
    constructor(id, name, pm, projectType, start, end, expectedEnd, state, progress, publishDate, wave ) {
      this.id = id;
      this.name = name;
      this.pm = pm;
      this.projectType = projectType;
      this.start = start;
      this.end = end;
      this.expectedEnd = expectedEnd;
      this.state = state;
      this.progress = progress;
      this.publishDate = publishDate;
      this.wave = wave;
    }
}

Without even sending it an object I'm getting this error in the page:

Uncaught TypeError: boolean false is not iterable (cannot read property Symbol(Symbol.iterator))

Is this not the correct way to ensure type specificity in Javascript React projects?

I'm getting my info from these resources:

As the project is still in the early phases I'm expecting this object to increase in size. Using a model in this way would greatly simplify having to look up the object keys.

Any help would be much appreciated.

If a (non-working) example would help then let me know and I can quickly put one together.

Cheers!

spoons
  • 75
  • 5

0 Answers0