React: Original error message is swallowed in an edge case with render phase updates

Created on 23 Jan 2019  Â·  5Comments  Â·  Source: facebook/react

"Cannot set property 'memoizedState' of null"

screen shot 2019-01-23 at 5 09 40 pm

  // Regression test
  fit('does not swallow original error when updating another component in render phase', () => {
    let {useState} = React;

    let _setState;
    function A() {
      const [, setState] = useState(0);
      _setState = setState;
      return null;
    }

    function B() {
      _setState(() => {
        throw new Error('Hello')
      });
    }

    expect(() =>
      ReactTestRenderer.create(
        <React.Fragment>
          <A />
          <B />
        </React.Fragment>,
      ),
    ).toThrow('Hello');
  });

Hooks Bug

Most helpful comment

I found a fix but thanks for the offer.

All 5 comments

I'd like to work on this issue if you don't mind.

I won't promise we won't fix it sooner — but if you can find the cause, it would be appreciated

I found a fix but thanks for the offer.

@gaearon just curious did you find the cause?

Yes I fixed it

Was this page helpful?
0 / 5 - 0 ratings