@react-native-firebase/admob 的基本用法给出:“TypeError: (0, _admob.default) is not a function".是否已弃用?或为什么不起作用? [英] Basic usage of @react-native-firebase/admob gives: "TypeError: (0, _admob.default) is not a function". Is it deprecated? or Why doesnt work?

查看:37
本文介绍了@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".是否已弃用?或为什么不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆