Component nesting is the process of nesting on the component inside another component.

we are changing file from  https://sandeshsardar.com/2018/04/03/basic-code-and-project-structure-in-react-native/

Index.js 

// Import a library to help create a component
import React from 'react';
import { AppRegistry, Text } from 'react-native';
import Header from './src/component/Header';

// Create a component
const App = () => (
  ‹Header/›
);

// Render it to the device
AppRegistry.registerComponent('MyNewProject', () => App);

Text : no need to import Text in Index.js as Header.js already importing Text

Header.js

// Import libraries for making a component
import React from 'react';
import { Text } from 'react-native';

// Make a component
const Header = () => {
  return (
  ‹Text› Header Text ‹/Text›
  );
};

// Make the component available to other parts of the app
export default Header;

 
240_F_77959340_hWLiOY93juohUoXqjKzqPB79552nw8XU

Hope you find this blog useful. Please feel free to contact with me in case you have any query, suggestions.  You can comment, like and follow posts.

You can request any topic related to Swift, React native and iOS development.

Advertisements