Skip to content

Maximum call stack exceeded with salePrice ref (video) #2

Open
@uturnr

Description

@uturnr

In the course video (but not the text below), the salePrice effect is declared after the total effect. This causes an infinite loop.

(Example of order in video)

effect(() => {
  total = salePrice.value * product.quantity
})
effect(() => {
  salePrice.value = product.price * 0.9
})

I added a check in the ref function to not set the value if it had not changed, which solved it for me:

    set value(newVal) {
      if (newVal !== raw) {
        raw = newVal
        trigger(r, 'value')
      }
    }

But then I came here to investigate and I noticed the difference, so I thought I'd point it out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions