报错`mobx.map` is deprecated, use `new ObservableMap` or `mobx.observable.map`instead
来源:互联网 发布:怎么自己开淘宝网店 编辑:程序博客网 时间:2024/06/07 02:00
首先贴出报错信息:
出错原因:
import { autorun, observable, map} from 'mobx';import React from 'react';import {Text} from 'react-native';export default function demo10() { const foo = map({}); autorun(()=>{ console.log(`map have ${foo.size} keys`); }); foo.set('foo',1); foo.set('bar',1); foo.set('foo',2); foo.delete('bar'); return <Text style={{margin:100}}>444</Text>}
解决办法:
map写法应该如下:
import { autorun, observable, map} from 'mobx';import React from 'react';import {Text} from 'react-native';export default function demo10() { const foo = observable.shallowMap({}); autorun(()=>{ console.log(`map have ${foo.size} keys`); }); foo.set('foo',1); foo.set('bar',1); foo.set('foo',2); foo.delete('bar'); return <Text style={{margin:100}}>444</Text>}
阅读全文
1 0
- 报错`mobx.map` is deprecated, use `new ObservableMap` or `mobx.observable.map`instead
- mobx装饰器使用报错指南
- android:password is deprecated: Use inputType instead
- android:password is deprecated: Use inputType instead
- MobX 入门教程
- EditText android:editable is deprecated: Use inputType instead
- ExtDeprecationWarning: Importing flask.ext.bootstrap is deprecated, use flask_bootstrap instead.
- DEPRECATED: Use of this script to execute hdfs command is deprecated. Instead use the hdfs command
- VS2015报错C4996处理,error C4996: 'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_D
- deprecated preg_replace the e modifier is deprecated use preg_replace_callback instead in
- Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in ...
- php报错:Deprecated: Assigning the return value of new by reference is deprecated in
- DEPRECATED: Use of this script to execute hdfs command is deprecated. Instead use the hdfs command f
- MOBX的入门案例
- React Native -- mobx
- React+mobx入门教程
- MobX API总览
- Mobx使用教程
- 求最短路即次短路模板,一条边可以重复走的HDU6181
- [笔记分享] [OS] Linux的时间管理
- leetcode75: Sort Colors
- R语言对高频交易订单流进行建模分析 1
- weex 学习历程
- 报错`mobx.map` is deprecated, use `new ObservableMap` or `mobx.observable.map`instead
- 1015:大小写问题
- var 与let const比较
- mybatis怎么返回某列的最大值
- 数据结构-图的应用之最短路径
- matplotlib.patches.Polygon
- short s1 = 1; s1 = s1 + 1;有错吗?short s1 = 1; s1 += 1;有错吗?【Java面试题】
- 深入浅出RxJava—基础篇
- java中poi模板下载