javascript-react-patterns
javascript-react-patterns copied to clipboard
Change singleton pattern counter class
Hi, the counter class gave me the following error messages:
- counter is not defined
- After initialization (this.counter = 0) "counter is read-only"
Removing Object.freeze and returning the instance in the constructor should resolve this issue.
Otherwise, as in the Objects example, counter can also be initiated outside the class: let counter = 0; After that, however, the "this" keyword would have to be removed from the methods.
Thanks!
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| fm-workshop-2 | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Aug 19, 2023 0:55am |