Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught (in promise) TypeError: Cannot read property 'firstChild' of undefined #8

Open
avdeev opened this issue Mar 20, 2020 · 2 comments

Comments

@avdeev
Copy link

avdeev commented Mar 20, 2020

Doesn't work for me. Failed with this error:

preact-shadow-root.es.js:17 Uncaught (in promise) TypeError: Cannot read property 'firstChild' of undefined
    at o.update (preact-shadow-root.es.js:17)
    at o.shouldComponentUpdate (preact-shadow-root.es.js:8)
    at A (index.js?c988:113)
    at eval (children.js?b0ec:95)
    at x (children.js?b0ec:252)
    at x (children.js?b0ec:254)
    at b (children.js?b0ec:43)
    at $ (index.js?c988:347)
    at A (index.js?c988:205)
    at eval (children.js?b0ec:95)
@iongion
Copy link

iongion commented Oct 11, 2020

I've go the same, apparently, this.base is null in componentDidMount

@iongion
Copy link

iongion commented Oct 11, 2020

I found a possible source for this, at least in my case

          const node = document.creatElement('<div>');
          render(
            <LoginDialog
              mode={context.mode}
              onLogin={options.onLogin}
              onLogout={options.onLogout}
              passwordRecoveryUrl={options.passwordRecoveryUrl}
            />,
            node,
            node.firstElementChild as Element
          );

So, the way I am injecting this is the culprit, node.firstElementChild is obviously empty.

Solution

          const node = document.creatElement('<div>');
          node.innerHTML = '<div></div>'; // <------ THIS LINE SOLVES IT, MAKES A firstElementChild exist
          render(
            <LoginDialog
              mode={context.mode}
              onLogin={options.onLogin}
              onLogout={options.onLogout}
              passwordRecoveryUrl={options.passwordRecoveryUrl}
            />,
            node,
            node.firstElementChild as Element
          );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants