Closed socheatleang closed 4 days ago
I connected with metamask on chain 43114, Then I try to switchNetwork by using useSwitchNetwork from wagmi@1.
"@web3modal/wagmi-react-native": "^1.3.0",
npx react-native info
System: OS: macOS 14.1 CPU: (8) x64 Apple M1 Pro Memory: 34.66 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 14.19.2 - ~/.nvm/versions/node/v14.19.2/bin/node Yarn: 1.22.18 - /opt/homebrew/bin/yarn npm: 6.14.17 - ~/.nvm/versions/node/v14.19.2/bin/npm Watchman: 2023.12.04.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.14.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 23.0, iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0 Android SDK: Android NDK: 22.1.7171670 IDEs: Android Studio: 2023.2 AI-232.10227.8.2321.11479570 Xcode: 15.0.1/15A507 - /usr/bin/xcodebuild Languages: Java: 20.0.2 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.71.14 => 0.71.14 react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found
"expo": "~48.0.21",
import { useNetwork, useSwitchNetwork, } from 'wagmi'; const Screen = () => { const { switchNetwork, chains } = useSwitchNetwork(); const { chain } = useNetwork(); useEffect(() => { // get the chain after wallet connected if (!chain?.id) return; if (chain?.id !== 137) { const targetChain = chains?.find((cin) => cin.id === 137); if (!targetChain) { alert('Target chain not found!'); return; } switchNetwork?.(targetChain?.id); } }, [chain, switchNetwork, chains]); }
Hey @socheatleang what's the issue exactly? Can you provide more details? And also a video could help
@socheatleang any new about this?
closing for now. I'll reopen if we have more info
Description
I connected with metamask on chain 43114, Then I try to switchNetwork by using useSwitchNetwork from wagmi@1.
Web3Modal SDK version
"@web3modal/wagmi-react-native": "^1.3.0",
Output of
npx react-native info
Expo Version (if applies)
"expo": "~48.0.21",
Steps to reproduce
Snack, code example, screenshot, or link to a repository