MOBX in the array need to be aware of the place

Source: Internet
Author: User

MOBX if the array is observable. You can observable by adding modifiers or call the observable method.

A lot of times, when we decorate this as an observable object, it's available everywhere.

For example, a method that uses native arrays such as map ForEach indexOf find can be used here.

But without noticing a problem, this object has become a Observable Array when printed in the console.

is not already an Array object.

When using methods such as the IsArray of Lodash, false is also returned

This time can be passed

Slice ()

method to convert to a native array. This is also stated in the official documentation.

Can be said intentionally, the eyes of the unintentional, aware of this, can avoid some very puzzling problems.

MOBX in the array need to be aware of the place

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.