{"id":22539,"date":"2018-08-31T12:15:13","date_gmt":"2018-08-31T09:15:13","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=22539"},"modified":"2018-08-31T11:11:02","modified_gmt":"2018-08-31T08:11:02","slug":"javascript-mobx","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/","title":{"rendered":"JavaScript: Upgrading from MobX 2.7.0 to 3.0.2"},"content":{"rendered":"<p>As usual, you should check out the <a href=\"https:\/\/github.com\/mobxjs\/mobx\/blob\/master\/CHANGELOG.md\">CHANGELOG<\/a>. However, let me point out a few things specifically:<\/p>\n<p>Don&#8217;t use the @action decorator on a singleton object that you pass to <code>observable()<\/code>. If you have code that looks like <code>observable({ @action f: () =&gt; {})<\/code>, you should change it to <code>observable({ f: action(() =&gt; {})<\/code>. Apparently, using decorators on singleton objects is a little sketchy. I assume the same thing applies to extendObservable. If you&#8217;re using classes, it&#8217;s a non-issue.<\/p>\n<p>If you have a resolution field in package.json that lists mobx, make sure you keep it in sync with the version of mobx you&#8217;re trying to install. Otherwise, you&#8217;ll end up with multiple versions of mobx, each with their own state, and that led to ultra-weird behavior for me.<\/p>\n<p>When passing an object to <code>observable()<\/code>, remember that it now makes a copy of that object. That was already the case for arrays and maps, but now it&#8217;s also the case for normal objects. Hence, when you pass an object into a store, stop using the reference to the old, non-observable object, and instead get a reference to the observable version of that object from the store.<\/p>\n<p>I saw some tests that would create some test object, do something that adds it to the store, and then assume that the original object reference was still valid. For instance:<\/p>\n<ul>\n<li>The code would use <code>.toBe<\/code> instead of <code>.toEqual<\/code>.<\/li>\n<li>The code would assume that if you added something to the original object, it&#8217;d be present in the object in the store.<\/li>\n<li>The code would assume that if you mutated the object in the store, it&#8217;d still match the data in the original object.<\/li>\n<li>The code would assume that you could compare the object in the store with the original object without using <code>toJS<\/code>. You should always use <code>toJS<\/code> when you compare an observable object with a non-observable test object.<\/li>\n<\/ul>\n<p>Aside from the &#8220;easy&#8221; stuff mentioned in the changelog, that&#8217;s pretty much it.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>Published on Web Code Geeks with permission by Shannon Behrens, partner at our <a href=\"\/\/www.webcodegeeks.com\/join-us\/wcg\/\" target=\"_blank\" rel=\"noopener\">WCG program<\/a>. See the original article here: <a href=\"https:\/\/www.jjinux.com\/2018\/08\/javascript-upgrading-from-mobx-270-to.html\" target=\"_blank\" rel=\"noopener\">JavaScript: Upgrading from MobX 2.7.0 to 3.0.2<\/a><\/p>\n<p>Opinions expressed by Web Code Geeks contributors are their own.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>As usual, you should check out the CHANGELOG. However, let me point out a few things specifically: Don&#8217;t use the @action decorator on a singleton object that you pass to observable(). If you have code that looks like observable({ @action f: () =&gt; {}), you should change it to observable({ f: action(() =&gt; {}). Apparently, &hellip;<\/p>\n","protected":false},"author":2215,"featured_media":920,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-22539","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JavaScript: Upgrading from MobX 2.7.0 to 3.0.2 - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Interested to learn more about mbox latest release in Javascript? Then check out our article on Upgrading from MobX 2.7.0 to 3.0.2!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript: Upgrading from MobX 2.7.0 to 3.0.2 - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Interested to learn more about mbox latest release in Javascript? Then check out our article on Upgrading from MobX 2.7.0 to 3.0.2!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/jjinux\" \/>\n<meta property=\"article:published_time\" content=\"2018-08-31T09:15:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Shannon Behrens\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@jjinux\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shannon Behrens\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/\"},\"author\":{\"name\":\"Shannon Behrens\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/e2d57d23e4b3598f8790df92623ca3d9\"},\"headline\":\"JavaScript: Upgrading from MobX 2.7.0 to 3.0.2\",\"datePublished\":\"2018-08-31T09:15:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/\"},\"wordCount\":360,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/\",\"name\":\"JavaScript: Upgrading from MobX 2.7.0 to 3.0.2 - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"datePublished\":\"2018-08-31T09:15:13+00:00\",\"description\":\"Interested to learn more about mbox latest release in Javascript? Then check out our article on Upgrading from MobX 2.7.0 to 3.0.2!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"JavaScript: Upgrading from MobX 2.7.0 to 3.0.2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/e2d57d23e4b3598f8790df92623ca3d9\",\"name\":\"Shannon Behrens\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/974735b0dd2b28e9ba02f5ebac09a19bfbca0375a57830af4430ed53927019e4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/974735b0dd2b28e9ba02f5ebac09a19bfbca0375a57830af4430ed53927019e4?s=96&d=mm&r=g\",\"caption\":\"Shannon Behrens\"},\"description\":\"Catholic, father of eight, open source enthusiast, Python, JavaScript, Ruby, Scala, Go, etc. programmer.\",\"sameAs\":[\"http:\/\/www.jjinux.com\",\"https:\/\/www.facebook.com\/jjinux\",\"www.linkedin.com\/in\/jjinux\",\"https:\/\/x.com\/jjinux\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/shannon-behrens\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript: Upgrading from MobX 2.7.0 to 3.0.2 - Web Code Geeks - 2026","description":"Interested to learn more about mbox latest release in Javascript? Then check out our article on Upgrading from MobX 2.7.0 to 3.0.2!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript: Upgrading from MobX 2.7.0 to 3.0.2 - Web Code Geeks - 2026","og_description":"Interested to learn more about mbox latest release in Javascript? Then check out our article on Upgrading from MobX 2.7.0 to 3.0.2!","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_author":"https:\/\/www.facebook.com\/jjinux","article_published_time":"2018-08-31T09:15:13+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","type":"image\/jpeg"}],"author":"Shannon Behrens","twitter_card":"summary_large_image","twitter_creator":"@jjinux","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Shannon Behrens","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/"},"author":{"name":"Shannon Behrens","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/e2d57d23e4b3598f8790df92623ca3d9"},"headline":"JavaScript: Upgrading from MobX 2.7.0 to 3.0.2","datePublished":"2018-08-31T09:15:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/"},"wordCount":360,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/","name":"JavaScript: Upgrading from MobX 2.7.0 to 3.0.2 - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","datePublished":"2018-08-31T09:15:13+00:00","description":"Interested to learn more about mbox latest release in Javascript? Then check out our article on Upgrading from MobX 2.7.0 to 3.0.2!","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-mobx\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"JavaScript: Upgrading from MobX 2.7.0 to 3.0.2"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/e2d57d23e4b3598f8790df92623ca3d9","name":"Shannon Behrens","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/974735b0dd2b28e9ba02f5ebac09a19bfbca0375a57830af4430ed53927019e4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/974735b0dd2b28e9ba02f5ebac09a19bfbca0375a57830af4430ed53927019e4?s=96&d=mm&r=g","caption":"Shannon Behrens"},"description":"Catholic, father of eight, open source enthusiast, Python, JavaScript, Ruby, Scala, Go, etc. programmer.","sameAs":["http:\/\/www.jjinux.com","https:\/\/www.facebook.com\/jjinux","www.linkedin.com\/in\/jjinux","https:\/\/x.com\/jjinux"],"url":"https:\/\/www.webcodegeeks.com\/author\/shannon-behrens\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/22539","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/2215"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=22539"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/22539\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/920"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=22539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=22539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=22539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}