@react-native-firebase/admob 的基本用法给出:“TypeError: (0, _admob.default) is not a function".是否已弃用?或为什么不起作用?

Basic usage of @react-native-firebase/admob gives: quot;TypeError: (0, _admob.default) is not a functionquot;. Is it deprecated? or Why doesnt work?(@react-native-firebase/admob 的基本用法给出:“TypeError: (0, _admob.default) is not a function.是否已弃用?或为什么不起作用?) -
本文介绍了@react-native-firebase/admob 的基本用法给出:“TypeError: (0, _admob.default) is not a function".是否已弃用?或为什么不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@react-native-firebase/admob 是否已弃用?或者只是......为什么它不起作用?

Is @react-native-firebase/admob deprecated? or just.. Why it doesn't work?

我正在使用 @react-native-firebase/admob (https://rnfb-docs.netlify.app/admob/usage).在使用admob()"之前一切正常.当我将 admob() 添加到代码时出现此错误:

I am using @react-native-firebase/admob (https://rnfb-docs.netlify.app/admob/usage). Everything works fine before to use "admob()". When I add admob() to the code appears this error:

TypeError: (0, _admob.default) 不是函数"

"TypeError: (0, _admob.default) is not a function"

有人知道为什么吗?

我的代码如下(基本用法):

My code below (basic usage):

import React from 'react';
import { Text, View} from 'react-native';
import admob, { MaxAdContentRating } from '@react-native-firebase/admob';
import { InterstitialAd, RewardedAd, BannerAd, TestIds } from '@react-native- 
firebase/admob';
import { BannerAdSize} from '@react-native-firebase/admob';



class App extends React.Component{

componentDidMount(){

// this was taked of official page: https://rnfb-docs.netlify.app/admob/usage#installation
admob()
  .setRequestConfiguration({
    // Update all future requests suitable for parental guidance
    maxAdContentRating: MaxAdContentRating.PG,

    // Indicates that you want your content treated as child-directed for purposes of COPPA.
    tagForChildDirectedTreatment: true,

    // Indicates that you want the ad request to be handled in a
    // manner suitable for users under the age of consent.
    tagForUnderAgeOfConsent: true,
  })
  .then(() => {
    // Request config successfully set!
  });
 }
render(){
return(
  <View style={{
    alignItems:"center", 
    justifyContent:"center",
    height:"100%"}}>
    <Text style={{color:"black"}}>
      Hola
    </Text>
    <BannerAd 
      unitId={TestIds.BANNER} 
      size={BannerAdSize.FULL_BANNER} />
  </View>
  )
 }
}
 export default App;


   

推荐答案

我能解决.

已解决

只需签入文件package.json"即可firebase 的软件包具有相同的版本,例如:

Just check in the file "package.json" that packages of firebase has the same version, example:

dependencies{
   "@react-native-firebase/admob": "^11.5.0",
   "@react-native-firebase/app": "^11.5.0"
}

提示

适用于类似错误.

这篇关于@react-native-firebase/admob 的基本用法给出:“TypeError: (0, _admob.default) is not a function".是否已弃用?或为什么不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)