株式会社シーポイントラボ | 浜松のシステム・RTK-GNSS開発

【react-native】Invariant Violation: Tried to register two views with the same name RCTTextInlineImageが起きる原因について

react-native-mapをインストールしてファイルに追加->ビルドしようとしたところ、以下のエラーが発生。

Invariant Violation: Tried to register two views with the same name RCTTextInlineImage

修正前のコード

import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

export default function App() {
  return (
    <View style={styles.container}>
      <Text>Open up App.js to start working on your app!</Text>
	<MapView
	    initialRegion={{
	      latitude: 37.78825,
	      longitude: -122.4324,
	      latitudeDelta: 0.0922,
	      longitudeDelta: 0.0421,
	    }}
	  />
      <StatusBar style="auto" />
    </View>
  );
}

mapとtextは同じview内で共存できない。

修正後のコード

import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, View } from 'react-native';

export default function App() {
  return (
    <View style={styles.container}>
	<MapView
	    initialRegion={{
	      latitude: 37.78825,
	      longitude: -122.4324,
	      latitudeDelta: 0.0922,
	      longitudeDelta: 0.0421,
	    }}
	  />
      <StatusBar style="auto" />
    </View>
  );
}

importのtextとview内にあったテキストを削除で解決。

  • この記事いいね! (0)
モバイルバージョンを終了