2

Working on an isomorphic app under Electrode framework and having debugging issue that I'm unable to solve. I believe, the framework here doesn't matter and you can reproduce the same easily.

Used: Redux, redux-thunk, redux-promise-middleware, redux-devtools-extension (helps to debug redux flow in with Chrome-extension).

The issue is that I don't receive the informative exception from the child element that makes the debugging a hell.

Will appreciate a lot for any hints on how to fix it. Providing a simplified code for the reference:

import React from "react";
import { render } from "react-dom";
import thunk from 'redux-thunk';
import promise from 'redux-promise-middleware';
import { applyMiddleware, createStore } from 'redux';
import { connect } from "react-redux";
import { composeWithDevTools } from 'redux-devtools-extension';

const rootReducer = function(state = { test: false }, action) {
  switch (action.type) {
    case 'TEST_FULFILLED': {
      state = {
        ...state,
        test: true
      };
      break;
    }
  }
  return state;
};

  const store = createStore(
    rootReducer,
    composeWithDevTools(
      applyMiddleware(promise(), thunk)
    )
  );

  const asyncCallAction = () => dispatch => {
    dispatch({
      type: 'TEST',
      payload: new Promise(resolve=>{
        resolve(true)
      })
    });
  };

  class Test extends React.Component {
    componentWillMount() {
      this.props.asyncCall();
    }

    render() {
      const { test } = this.props;
      console.log('Test Value: ', test)
      return (
        <div>
          If test passed you should see the output below, or the exception in console:

          {
            test && // No exception shown regarding the invalid child element shown
            // test && // If commented, shows the exception from the invalid child element
            <ElementWithError someState={true} />
          }
        </div>
      );
    }
  }

  class ElementWithError extends React.Component {
    render() {

      ThrowError(); // Expecting: ThrowError is not defined exception

      return <div>
        Test Passed
      </div>
    }
  }

  const mapStateToProps = state => {
    return {
      test: state.test
    };
  };


  const Render = connect(mapStateToProps, dispatch => ({
    dispatch,
    asyncCall: ()=>dispatch(asyncCallAction()),
  }))(Test);


  render(
    <Render store={store} />,
    document.querySelector('.js-content')
  );
user1537407
  • 55
  • 1
  • 5
  • not much help i know but in my environment, if i implement ThrowError, it outputs as expected – hairmot Jul 29 '17 at 12:43
  • Could you please provide more info on ThrowError? Is it a middleware? Where to find it? – user1537407 Jul 29 '17 at 19:46
  • at the bottom of your file just add: function ThrowError() {console.log('error thrown')} – hairmot Jul 31 '17 at 08:20
  • The goal is to see the native exception in browser console log. – user1537407 Aug 03 '17 at 09:27
  • Possible duplicate of [How to see React tab in Chrome devtools when debugging React-Native app?](https://stackoverflow.com/questions/35338412/how-to-see-react-tab-in-chrome-devtools-when-debugging-react-native-app) – Paul Sweatte Aug 30 '17 at 09:18
  • Nothing in common with that topic. It's a web-app and the issue is that the exception is not thrown in console log. – user1537407 Oct 06 '17 at 19:16

0 Answers0