0

Since im building my webapp with React, when i try to set something into an undefined object property, the code processing crashes (reproducible with breakpoint debugging) and no errors are shown in the console log. Also the chrome react extension does not give me any errors.

So to finding a bug is more time consuming that it should be.

let changedJsonResponse = jsonResponse;
changedJsonResponse.data = newTableData; // changedJsonResponse.data is undefined

// throws no error & code proccess crashes

webpack.config.js

const webpack = require('webpack');
const path = require('path');

let config = {
    devtool: 'eval-source-map',
    entry: {
        FooManagement: ['babel-polyfill', './domains/FooManagement/entry.jsx'],
    },
    output: {
        path: path.resolve(__dirname, '../web/react/'),
        filename: '[name].js'
    },
    externals: {
        'jquery': 'window.jQuery',
        'bootbox': 'window.bootbox',
    },
    resolve: {
        alias: {
            alias_shared: path.resolve(__dirname, 'shared'),
        },
    },
    module: {
        rules: [
            {
                test: /\.jsx?$/,
                exclude: [/node_modules/],
                loader: 'babel-loader',
                options: {presets: ['es2015', 'react']}
            },
            {
                test: /\.css/,
                loader: 'style-loader!css-loader'
            }
        ]
    }
};

module.exports = config;

package.json

{
  "author": "myself",
  "version": "0.0.1",
  "description": "",
  "main": "index.jsx",
  "scripts": {
    "watch": "webpack -d --watch",
    "build": "webpack -p"
  },
  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-polyfill": "^6.26.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "css-loader": "^0.28.7",
    "style-loader": "^0.19.0",
    "webpack": "^3.8.1"
  },
  "dependencies": {
    "axios": "^0.16.2",
    "dateformat": "^3.0.2",
    "is-uuid": "^1.0.2",
    "lodash": "^4.17.4",
    "react": "^16.0.0",
    "react-cropper": "^1.0.1",
    "react-dom": "^16.0.0",
    "react-dropzone": "^4.2.3",
    "react-router-dom": "^4.2.2",
    "react-switchery-component": "0.0.7",
    "uuid": "^3.1.0"
  }
}

Chrome version: 62.0.3202.94

7
  • What is the error here changedJsonResponse.data = newTableData; ? Commented Dec 14, 2017 at 7:47
  • Okay, changedJsonResponse.data is undefined. If changedJsonResponse exists, like { }, then this will work. Am I misunderstood you question? Commented Dec 14, 2017 at 7:49
  • Like i described in the code block, the property data is undefined. // changedJsonResponse.data is undefined. I noticed that the problem comes also when setting something into an undefined variable. Commented Dec 14, 2017 at 7:49
  • If changedJsonResponse is some object and changedJsonResponse.data is undefined then changedJsonResponse.data = newTableData will not throw any error. Commented Dec 14, 2017 at 7:49
  • @Prakashsharma Thats the problem. But it should throw an error, the code proccess is also halted then. Commented Dec 14, 2017 at 7:52

1 Answer 1

0

I was able to catch those errors in Axios .catch.

After a while i found the cause of the problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.