Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

writing multiple functional components in single file in react

/*
|========================================================================
| How To Create Multiple Functional Components in React in Single File
|========================================================================
*/

// ====== MULTIPLE FUNCTIONAL COMPONENTS IN SINGLE FILE ======
export const component1 = () => {
   return <div>Hello From Component 1</div>
}

export const component2 = () => {
   return <div>Hello From Component 2</div>
}


// ===== IMPORT THESE COMPONENT IN ANY COMPONENT LIKE THIS =====
import {component1, component2 } from './component.js'

 
PREVIOUS NEXT
Tagged: #writing #multiple #functional #components #single #file #react
ADD COMMENT
Topic
Name
5+7 =