2017-02-01 8 views
1

私はmobxを愛していて、いくつかのタブレットで小さなアプリを実装していて、Android WebViewで古いjavascriptの問題に遭遇しました(これは年齢錠剤の)。mobx @ observableは古いAndroid 4.4 Tabletでエラーをスローする

アンドロイドタブレット:ネクサス4.4(ロリポップ)

それはmobx.jsファイル(下記の関数)で周り2740でのように見えるものの、エラーが、以下では、古いjavascriptのエンジンを搭載した@observablesとの問題を抱えています。

私は現在、私のjsを蒸散するためにwebpack(下記参照)を使用しています。私が実際にmobxを使用したいと思っているので、これに関する助けがあれば幸いです。 mobx.js

function isES6Map (thing) { 
    if (thing instanceof getGlobal().Map) { 
    return true; 
    } 
    return false; 
} 

コンソールエラーで心から

、 クリス

行2740:

[mobx]反応や観察者によってスローされたCatchedキャッチされない例外コンポーネント:in 'Reaction [CustomerFeedback#0.render()] TypeError メッセージ: "インスタンスチェックの関数を期待していますが、場所を取得しました - ページ" スタック:(...) スタックを取得する:function(){[native code]} set stack:function(){[native code]} proto :エラー 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: '' 
    }); 
    }, 
    // ... 
} 
+0

実際にあなたのコードに 'babel-polyfill'を使用していますか? "import" babel-polyfill "; ' – Tholle

+1

yes @Tholle、webpack.configにあります:エントリ:[' babel-polyfill '、' ./index.js ']、 – Centinel3

+0

ああ、私はそれを逃しました。とても興味深い。 [**問題を作成する]価値があるかもしれません(https://github.com/mobxjs/mobx/issues/new)? – Tholle

答えて

2

この問題は、先週の3.0.2リリースで修正されました(mobx開発者からのフィードバックによる)。

関連する問題