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.

Hosted fields throws an error when passing container in React 16

See original GitHub issue

General information

  • SDK version: 3.57
  • Environment: Sandbox
  • Browser and OS: Chrome 79 Windows 10

Issue description

When trying to use container instead of selector during hosted fields configuration, it gives an error:

Could not stringify event: Converting circular structure to JSON
    --> starting at object with constructor 'HTMLDivElement'
    |     property '__reactInternalInstance$ahvo3qp93tt' -> object with constructor 'FiberNode'
    --- property 'stateNode' closes the circle

I’m using React 16.12 and here’s my configuration:

const cardNumberRef = useRef(null);
...
braintree.hostedFields.create(
    {
        client: clientInstance,
        fields: {
            number: {
                container: cardNumberRef.current,
                placeholder: "4111 1111 1111 1111"
            },
    ...
...
<div 
    ref={cardNumberRef}
    id="card-number"
    className="hosted-field"
></div>

It’s trying to JSON.stringify options during following call (hosted-fields.js:613) reply(self._merchantConfigurationOptions); and fails because some of them are HTMLDivElement instances (see screenshot)

Screenshot_7

From the changelog I see that container param for field is supported since 3.47.0. What am I missing here?

Thanks.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
crookedneighborcommented, Feb 13, 2020

👍 I’ve got a fix started that drops the container field before sending it to the hosted fields iframes. Will update here when it’s released.

0reactions
wiranoidcommented, Feb 13, 2020

Yes, it’s working now. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Handling in React 16 – React Blog
As React 16 release is getting closer, we would like to announce a few changes to how React handles JavaScript errors inside components....
Read more >
JSX element type Elem does not have any construct or call ...
Simply speaking, the type React.Component<any, any> used is the wrong type which remains unresolved. I used React.FunctionComponent and it worked for me.
Read more >
How To Manage State with Hooks on React Components
By passing an empty array as an argument to useState , you set the initial empty state as the first value of cart...
Read more >
Use React and Spring Boot to Build a Simple CRUD App
React is one of the most popular JavaScript frameworks, ... You will need Java 17 and Node 16 installed to complete this tutorial....
Read more >
Stripe JS Reference
fields object. Pass an object to specify payment fields you don't want to collect with the Payment Element.
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