Vamsi
Vamsi

Reputation: 392

How to use container in react native?

I am very new to React native I am trying to show content it is showing from starting. But I have To show the content from the container, but I don't know how to apply this in React native. So So someone please help me how to use container in React native.

In this component I tried some code please check it once

This is App.js

import React from 'react';
import {View, Text} from 'react-native';

const App = props => {
  return (
    <View>
      <Text>Hi Mark</Text>
    </View>
  );
};

export default App;

These are the packages I installed in my React native project

{
  "name": "testone",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/masked-view": "^0.1.10",
    "@react-navigation/native": "^5.3.2",
    "@react-navigation/stack": "^5.3.6",
    "react": "16.11.0",
    "react-native": "0.62.2",
    "react-native-gesture-handler": "^1.6.1",
    "react-native-reanimated": "^1.8.0",
    "react-native-safe-area-context": "^1.0.0",
    "react-native-screens": "^2.7.0"
  },
  "devDependencies": {
    "@babel/core": "7.9.6",
    "@babel/runtime": "7.9.6",
    "@react-native-community/eslint-config": "0.0.5",
    "babel-jest": "24.9.0",
    "eslint": "6.8.0",
    "jest": "24.9.0",
    "metro-react-native-babel-preset": "0.58.0",
    "react-test-renderer": "16.11.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

Note I am not using expo I am using pure React native for app development.

Upvotes: 0

Views: 956

Answers (1)

Ferin Patel
Ferin Patel

Reputation: 3968

Add margin style property to root View to make it like container

import React from "react";
import { Text, View } from "react-native";

const App = () => {
  return (
    <View style={{ margin:100 }}>
      <Text>Hi There!</Text>
    </View>
  );
};

export default App;

Upvotes: 2

Related Questions