mobx @observable 在旧 Android 4.4 平板电脑上抛出错误
mobx @observable throws error on older Android 4.4 Tablet
我喜欢 mobx,并在一些平板电脑上实现了一个小应用程序,并且 运行 解决了 Android WebView 上旧 javascript 的问题(我无法升级由于平板电脑的年龄)。
Android 平板电脑:Nexus 4.4(棒棒糖)
下面是错误,虽然看起来 mobx.js 文件(下面的函数)中的 2740 左右与旧的 javascript 引擎的@observables 有问题。
我目前正在使用 webpack(见下文)来构建我的 js。运行任何对此的帮助将不胜感激,因为我真的很想继续使用 mobx。
真诚的,
克里斯
第 2740 行 mobx.js
function isES6Map (thing) {
if (thing instanceof getGlobal().Map) {
return true;
}
return false;
}
控制台错误:
[mobx] 捕获到反应或观察者组件抛出的未捕获异常,在:'Reaction[CustomerFeedback#0.render()]
类型错误
消息:"Expecting a function in instanceof check, but got locations-page"
堆: (...)
获取堆栈:函数(){[本机代码]}
设置堆栈:function () { [native code] }
原型:错误
mobx.js:1284
Reaction.reportExceptionInDerivation
webpack:
'use strict';
const autoprefixer = require('autoprefixer');
const copyWebpackPlugin = require('copy-webpack-plugin');
const extractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');
const scssLoaders = [
'css-loader',
'postcss-loader',
'sass-loader?indentedSyntax=false&includePaths[]=' + path.resolve(__dirname, './application')
];
const config = {
debug: true,
devtool: 'source-map',
entry: ['babel-polyfill', './index.js'],
module: {
loaders: [
{
test: /.(js|jsx)$/,
exclude: /node_modules/,
loader: ['babel-loader'],
query: {
cacheDirectory: true,
plugins: [
'transform-decorators-legacy',
'transform-class-properties',
'mobx-deep-action'
],
presets: ['es2015', 'stage-0', 'react'],
babelrc: false
}
},
{
test: /.scss$/,
loader: extractTextPlugin.extract('style-loader', scssLoaders.join('!'))
},
{
test: /.(svg|jpg|png)$/,
loader: 'file-loader?name=/media/[name].[ext]'
}
]
},
output: {
path: path.join(__dirname, './build'),
publicPath: '/build',
filename: '[name].js'
},
plugins: [
new extractTextPlugin('[name].css')
],
postcss: [
autoprefixer({
browsers: ['last 2 versions']
})
],
resolve: {
extensions: ['', '.js', '.jsx', '.scss'],
modulesDirectories: ['./node_modules/'],
root: [path.join(__dirname, './application')]
}
};
module.exports = config;
appState 文件:
import { action, computed, extendObservable, toJS } from 'mobx';
class CustomerFeedbackState {
constructor() {
// Initializes all observables
this.initializeStoreData();
}
/* ACTIONS */
// Initialize the store's state, allowing a reinitialization of the app as needed (reset to default state)
@action initializeStoreData() {
extendObservable(this, {
// Keeps track of what page the user is on - 'locations-page' is the start page
currentPageName: 'locations-page',
// Keeps track of what question is being asked
currentQuestionNumber: 0,
// Set to true when the JSON data comes back successful
dataFetched: false,
// sets the active state for the next button
disableNextPage: true,
// Keeps track of page history
lastPageVisitedArray: [],
// Current Location Id
locationId: 0,
// Mood link active states
moodLinkHappyIsActive: false,
moodLinkNeutralIsActive: false,
moodLinkSadIsActive: false,
// Next page available
nextPage: '',
// User mood
userMood: ''
});
},
// ...
}
上周 3.0.2 版本修复了这个问题(根据 mobx 开发人员的反馈)。
我喜欢 mobx,并在一些平板电脑上实现了一个小应用程序,并且 运行 解决了 Android WebView 上旧 javascript 的问题(我无法升级由于平板电脑的年龄)。
Android 平板电脑:Nexus 4.4(棒棒糖)
下面是错误,虽然看起来 mobx.js 文件(下面的函数)中的 2740 左右与旧的 javascript 引擎的@observables 有问题。
我目前正在使用 webpack(见下文)来构建我的 js。运行任何对此的帮助将不胜感激,因为我真的很想继续使用 mobx。
真诚的, 克里斯
第 2740 行 mobx.js
function isES6Map (thing) {
if (thing instanceof getGlobal().Map) {
return true;
}
return false;
}
控制台错误:
[mobx] 捕获到反应或观察者组件抛出的未捕获异常,在:'Reaction[CustomerFeedback#0.render()] 类型错误 消息:"Expecting a function in instanceof check, but got locations-page" 堆: (...) 获取堆栈:函数(){[本机代码]} 设置堆栈:function () { [native code] } 原型:错误 mobx.js:1284 Reaction.reportExceptionInDerivation
webpack:
'use strict';
const autoprefixer = require('autoprefixer');
const copyWebpackPlugin = require('copy-webpack-plugin');
const extractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');
const scssLoaders = [
'css-loader',
'postcss-loader',
'sass-loader?indentedSyntax=false&includePaths[]=' + path.resolve(__dirname, './application')
];
const config = {
debug: true,
devtool: 'source-map',
entry: ['babel-polyfill', './index.js'],
module: {
loaders: [
{
test: /.(js|jsx)$/,
exclude: /node_modules/,
loader: ['babel-loader'],
query: {
cacheDirectory: true,
plugins: [
'transform-decorators-legacy',
'transform-class-properties',
'mobx-deep-action'
],
presets: ['es2015', 'stage-0', 'react'],
babelrc: false
}
},
{
test: /.scss$/,
loader: extractTextPlugin.extract('style-loader', scssLoaders.join('!'))
},
{
test: /.(svg|jpg|png)$/,
loader: 'file-loader?name=/media/[name].[ext]'
}
]
},
output: {
path: path.join(__dirname, './build'),
publicPath: '/build',
filename: '[name].js'
},
plugins: [
new extractTextPlugin('[name].css')
],
postcss: [
autoprefixer({
browsers: ['last 2 versions']
})
],
resolve: {
extensions: ['', '.js', '.jsx', '.scss'],
modulesDirectories: ['./node_modules/'],
root: [path.join(__dirname, './application')]
}
};
module.exports = config;
appState 文件:
import { action, computed, extendObservable, toJS } from 'mobx';
class CustomerFeedbackState {
constructor() {
// Initializes all observables
this.initializeStoreData();
}
/* ACTIONS */
// Initialize the store's state, allowing a reinitialization of the app as needed (reset to default state)
@action initializeStoreData() {
extendObservable(this, {
// Keeps track of what page the user is on - 'locations-page' is the start page
currentPageName: 'locations-page',
// Keeps track of what question is being asked
currentQuestionNumber: 0,
// Set to true when the JSON data comes back successful
dataFetched: false,
// sets the active state for the next button
disableNextPage: true,
// Keeps track of page history
lastPageVisitedArray: [],
// Current Location Id
locationId: 0,
// Mood link active states
moodLinkHappyIsActive: false,
moodLinkNeutralIsActive: false,
moodLinkSadIsActive: false,
// Next page available
nextPage: '',
// User mood
userMood: ''
});
},
// ...
}
上周 3.0.2 版本修复了这个问题(根据 mobx 开发人员的反馈)。