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.

Invariant Violation: [...,"top: <<NaN>>",...] is not usable as a native method argument

See original GitHub issue

Explain what you did

I use “tooltip” to indicate a message when a user press on a text. This tooltip is located on a text that is in an Item of a flatlist.

Expected behavior

I want the tooltip to show up!

Describe the bug

The tooltip works very well! However, if the flatlist item is located very low in the flatlist rendering window and I click on the text, I get an ugly error like this:

Tip: It only seems to happen on Android.

To Reproduce

  • Make a flatlist with some large (in height) item
  • Put a text at the bottom of this item
  • Create an absolute view that wrap the text and apply it a tooltip (cause there is a problem with statusbar on Android)
  • Scroll the items, when a text with tooltip is at the bottom of the rendering window, click on it.

Screenshots

Screenshot_2020-01-11-11-44-16

Your Environment (please complete the following information):

react-native info

System:
    OS: macOS 10.14.6
    CPU: (4) x64 Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
    Memory: 1.69 GB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.16.1 - /usr/local/bin/node
    npm: 6.13.4 - ~/.npm-global/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 10.3/10G8 - /usr/bin/xcodebuild
  npmPackages:
    @react-native-community/cli: ^3.0.4 => 3.0.4
    react: 16.8.6 => 16.8.6
    react-native: 0.60.4 => 0.60.4
react-native elements version

react-native-elements": "^1.1.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

13reactions
LucidNinjacommented, May 8, 2020

I was getting this issue but managed to fix it by waiting for the screen to finish painting, by using the requestAnimationFrame method

requestAnimationFrame(() => tooltipRef.current?.toggleTooltip());

5reactions
renjfkcommented, Mar 4, 2021

This is still occurring for some cases especially on simulator and when hermes is enabled which ends up with app crashing. For now as workaround providing default values to measure callback seems to be resolving issue at least for my situation (manual toggle). Even if it gets wrong positioning at first since toggleTooltip hence getElementPosition is called every time it ends up with correct ones ultimately without any glitch. I could create another PR for this kind of situation as safety measure since I don’t see any harm with this kind of change.

...
  getElementPosition = () => {
    const { skipAndroidStatusBar } = this.props;
    this.renderedElement &&
      this.renderedElement.measure(
        (
          frameOffsetX,
          frameOffsetY,
          width = 0,
          height = 0,
          pageOffsetX = 0,
          pageOffsetY = 0
        ) => {
...
Read more comments on GitHub >

github_iconTop Results From Across the Web

Invariant Violation: is not usable as a native method argument ...
I figured the issue was that I am giving a null value to a styling. So look at each of your style and...
Read more >
React Native, 'is not usable as a native method argument'
This kind of error comes when you pass something inappropriate to the property. For example, I was not passing the ...
Read more >
React Native, 'is not usable as a native method argument'
Coding example for the question React Native, 'is not usable as a native method argument'-React Native.
Read more >
Troubleshooting common React Native bugs - LogRocket Blog
This troubleshooting guide shares how to easily find and address common React Native bugs. See common error examples.
Read more >
RCTVIEW [{flexGrow:<<Nan>>}] is not usable as a native ...
RCTVIEW [{flexGrow:< >}] is not usable as a native method argument. ... is not usable as a native method argument. react-native-video-player.
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