question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] 'Cannot set property 'innerHTML' of undefined' on createWidget if React ref.current is used as element (since release v1.0 !)

See original GitHub issue

Describe the bug

The v1.0 version of this package gives an undefined error on createWidget(element, …) if passed a ref.current value in React.

This worked fine in version 0.34.6. Also, makeWidget is now createWidget apparently, so I think the docs are lagging behind.

To Reproduce Steps to reproduce the behavior:

  1. Install @typeform/embed (latest)
  2. Add the following code:
import React, { useRef, useEffect } from 'react'
import * as typeformEmbed from '@typeform/embed'

const MyTypeform = () => {
  const typeformRef = useRef(null)

  useEffect(() => {
    typeformEmbed.makeWidget(typeformRef.current, 'https://form.typeform.com/to/MY_TYPEFORM_ID', {
      hideFooter: true,
      hideHeaders: true,
      opacity: 50,
    })
  }, [typeformRef])

  return <div ref={typeformRef} style={{ height: '100vh', width: '100%' }}></div>
}

Expected behavior I expect the form embed to load as usual.

Current behavior The ref.current value seems to be handled incorrectly when the createWidget method is called.

Problem 1: makeWidget does not exist anymore, please update the docs.

Typeform error

Problem 2: 'Cannot set property ‘innerHTML’ of undefined

Typeform error 2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:7

github_iconTop GitHub Comments

2reactions
wisejaydencommented, Mar 15, 2021

This is still an issue, bad bot.

0reactions
mathiocommented, Apr 15, 2021

Sorry about the delay on releasing the documentation. it is now up to date for version >= 1 on both Github and our developers portal.

You can also find the latest examples in demo packages in the repo, there is also an example for React.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Ref - Cannot set property 'innerHTML' of null
The most likely reason why you are getting the error is that your refs are not attached to a DOM element. If you...
Read more >
Content - 3811e52cdfcda707d47b0ed2f8fb560e94e67923
This attribute is used to reference another element by `name` or `id`. Since the `name` and `id` attributes are already blacklisted, a sanitized...
Read more >
Uncaught TypeError: Cannot set property 'innerHTML' of null
Uncaught TypeError: Cannot set property 'innerHTML' of null. I'm trying to change the text of a list component based on data I've pulled...
Read more >
2008-April.txt - Python mailing list
Python 2.5 does a somewhat better job of releasing memory when actual use falls below peak, but this is a difficult thing to...
Read more >
JavaScript-Cookbook-2nd-Edition.pdf - Pepa
Her recent O'Reilly books have covered JavaScript, HTML5 media objects, Ajax, and web graphics. Twitter: @oreillymedia facebook.com/oreilly. Problem solving ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found