tamagui icon indicating copy to clipboard operation
tamagui copied to clipboard

Error trying to use Tamagui Core in vanilla React Native project

Open Drew-Gerber opened this issue 2 years ago • 6 comments

Describe the bug

When calling setupReactNative from @tamagui/core, I get the error WeakMap key must be an Object.

I'm trying to use Tamagui Core in a vanilla React Native app with React Native 0.70.6. Upon following the configuration steps for @tamagui/core, I see the error below: image

To Reproduce

In a vanilla RN app, follow the steps outlined in the Tamagui Core configuration section: https://tamagui.dev/docs/core/configuration

  1. Add the following libraries to your app:
    "@tamagui/animations-reanimated": "1.1.5",
    "@tamagui/config-base": "1.1.5",
    "@tamagui/core": "1.1.5",
    "@tamagui/theme-base": "1.1.5",
  1. Have a config file detailed in the configuration docs.
  2. Wire up a provider
  3. Open app, see error shown in above screenshot.

System Info (please complete the following information):

Output of npx envinfo --system --npmPackages --binaries --browsers:

System:
    OS: macOS 13.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 36.45 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    Yarn: 3.2.3 - ~/.nvm/versions/node/v16.15.1/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
    Watchman: 2023.01.16.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 109.0.5414.119
    Safari: 16.2
  npmPackages:
    @tamagui/animations-reanimated: 1.1.5 => 1.1.5 
    @tamagui/config-base: 1.1.5 => 1.1.5 
    @tamagui/core: 1.1.5 => 1.1.5 
    @tamagui/theme-base: 1.1.5 => 1.1.5 
    react-native: 0.70.6 => 0.70.6 
    react-native-reanimated: 2.13.0 => 2.13.0 

  • [ ] yarn.lock or similar
  • [ ] If it's a specific file, add //! debug to the top (the ! works in esbuild compiled packages but not necessary always) and include that (only for compiler, but helps to know if it's on or off).
  • [ ] Run your server/bundler with DEBUG=tamagui and include that output at the bottom.

Drew-Gerber avatar Jan 26 '23 21:01 Drew-Gerber

Same here...

paulovitin avatar Jan 27 '23 02:01 paulovitin

Can't make it work

AguSandoval avatar Jan 27 '23 13:01 AguSandoval

Think this might be fixed in 1.1.7 via this PR: https://github.com/tamagui/tamagui/pull/595

Will validate and close this if so!

Drew-Gerber avatar Jan 30 '23 16:01 Drew-Gerber

@Drew-Gerber did it worked?

AguSandoval avatar Feb 01 '23 23:02 AguSandoval

@AguSandoval I get a different error now - this appears to be because I don't have certain native modules installed/linked when using a newly created React Native project via the RN CLI. Here's the error: image

I've resorted to doing the below for now - and only adding views that I need to setupReactNative's argument:

import {Text, View, Image} from 'react-native';

setupReactNative({View, Text, Image});

Drew-Gerber avatar Feb 06 '23 14:02 Drew-Gerber

@AguSandoval I get a different error now - this appears to be because I don't have certain native modules installed/linked when using a newly created React Native project via the RN CLI. Here's the error: image

I've resorted to doing the below for now - and only adding views that I need to setupReactNative's argument:

import {Text, View, Image} from 'react-native';

setupReactNative({View, Text, Image});

Seeing this as well

JackCA avatar Mar 12 '23 05:03 JackCA

i can't imagine how this would be cause by use, setupReactNative does almost nothing, i think it just looks like its coming from there. but either way the newest versions are a lot safer as they carefully isolate things even if you don't set TAMAGUI_TARGET, so i think this is fixed

natew avatar Sep 10 '23 21:09 natew