Skip to content

Doesn't work with react-native-admob after detaching #285

@deadcoder0904

Description

@deadcoder0904

Idk if its the issue with react-native-admob or expo or both so I'm creating it in both places

The following errors are produced -

Warning: Native component for "RNAdMob" does not exist

Warning: View.propTypes has been deprecated and will be removed in a future version of ReactNative. Use ViewPropTypes instead.

Warning: Native component for "RNAdMobDFP" does not exist

First I created a project using create-react-native-app which uses Expo then I detached using exp detach then I added react-native-admob using yarn add react-native-admob & then did react-native link

My Main File looks like this -

import React from 'react';
import { Font } from 'expo';
import { StyleSheet, Text, View } from 'react-native';
import { 
  AdMobBanner, 
  AdMobInterstitial, 
  PublisherBanner,
  AdMobRewarded
} from 'react-native-admob';

export default class App extends React.Component {
  state = {
    fontLoaded: false,
  };

  componentDidMount() {
    Font.loadAsync({
      'open-sans-bold': require('./assets/fonts/OpenSans-Bold.ttf'),
    }).then(_ => this.setState({ fontLoaded: true }));
  }

  render() {
    return (
      <View style={styles.container}>
        {
          this.state.fontLoaded ? (
            <View>
              <Text style={styles.text}>
                Open up App.js to start working on your app!
              </Text>
              <AdMobBanner
                bannerSize="fullBanner"
                adUnitID="ca-app-pub-1425926517331745/4411715717"
                testDeviceID="EMULATOR"
                didFailToReceiveAdWithError={this.bannerError} 
              />
            </View>
          ) : null
        }
      </View>
    )
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
  text: {
    fontFamily: 'open-sans-bold'
  }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions