Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

•“In React, everything is a component.” Explain

“In React, everything is a component.” Explain.
Components are the building blocks of a React application's UI.
These components split up the entire UI into small independent and reusable pieces.
Then it renders each of these components independent of each other 
without affecting the rest of the UI
Comment

react component

/* functional React component template */

import React, { useState, useEffect } from "react"

export default const MyComponent = () => {
  const [item, setItem] = useState();
  
  useEffect(() => {
    
  }
  
  return (
  	<div></div>
  )
}
Comment

components in react

//Use a pure stateless component
export const myComponent = () => return ()
// Stateful
export class myComponent extends React.Component {
  //use Hooks for more comfort
  ...
} 
Comment

react component

import React from 'react';
import ReactDOM from 'react-dom';
 
class MyComponentClass extends React.Component {
  render() {
    return <h1>Hello world</h1>;
  }
}
 
ReactDOM.render(
    <MyComponentClass />, 
    document.getElementById('app')
);
Comment

react component

import React from 'react';
import {
    MDBFooter,
    MDBContainer,
    MDBIcon,
    MDBBtn
  } from 'mdb-react-ui-kit';
//this is a react Footer Component , try it..
  export default function Footer(){


return(<>
<div className="footer">
     <MDBFooter className='bg-dark text-center text-white'>
      <MDBContainer className='p-4 pb-0'>
        <section className='mb-4'>
          <MDBBtn
            floating
            className='m-1'
            style={{ backgroundColor: '#3b5998' }}
            href='#!'
            role='button'
          >
            <MDBIcon fab icon='facebook-f' />
          </MDBBtn>
          
        
          <MDBBtn
            floating
            className='m-1'
            style={{ backgroundColor: '#55acee' }}
            href='#!'
            role='button'
          >
            <MDBIcon fab icon='twitter' />
          </MDBBtn>

          <MDBBtn
            floating
            className='m-1'
            style={{ backgroundColor: '#dd4b39' }}
            href='#!'
            role='button'
          >
            <MDBIcon fab icon='google' />
          </MDBBtn>
          <MDBBtn
            floating
            className='m-1'
            style={{ backgroundColor: '#ac2bac' }}
            href='#!'
            role='button'
          >
            <MDBIcon fab icon='instagram' />
          </MDBBtn>

          <MDBBtn
            floating
            className='m-1'
            style={{ backgroundColor: '#0082ca' }}
            href='#!'
            role='button'
          >
            <MDBIcon fab icon='linkedin-in' />
          </MDBBtn>

          <MDBBtn
            floating
            className='m-1'
            style={{ backgroundColor: '#333333' }}
            href='#!'
            role='button'
          >
            
            <MDBIcon fab icon='github' />
          </MDBBtn>
        </section>
      </MDBContainer>

      <div className='text-center p-3' style={{ backgroundColor: 'rgba(0, 0, 0, 0.2)' }}>
        © 2020 Copyright:
        <a className='text-white' href='https://mohammadsh96.github.io/portfoilo/'>
          Mohammad ALshraideh
        </a>
      </div>
    </MDBFooter>
    </div>
    </>)

  }
Comment

react component

import React from 'react';
import {
  MDBNavbar,
  MDBContainer,
  MDBIcon,
  MDBNavbarNav,
  MDBNavbarItem,
  MDBNavbarLink
} from 'mdb-react-ui-kit';

export default function App() {
  return (
    <MDBNavbar expand='lg' light bgColor='light'>
      <MDBContainer fluid>
        <MDBNavbarNav className='d-flex flex-row'>
          <MDBNavbarItem className='me-3 me-lg-0'>
            <MDBNavbarLink href='#'>
              <MDBIcon fas icon='shopping-cart' />
            </MDBNavbarLink>
          </MDBNavbarItem>
          <MDBNavbarItem className='me-3 me-lg-0'>
            <MDBNavbarLink href='#'>
              <MDBIcon fab icon='twitter' />
            </MDBNavbarLink>
          </MDBNavbarItem>
        </MDBNavbarNav>
      </MDBContainer>
    </MDBNavbar>
  );
}
Comment

what is components in react

Components are independent and reusable bits of code. 
Comment

PREVIOUS NEXT
Code Example
Javascript :: updating an array of object in mongoose 
Javascript :: Update matched key values in two JavaScript objects 
Javascript :: settimeout js 
Javascript :: sort list of objects by value node js 
Javascript :: form an array from i to j javascript 
Javascript :: how to add the click event into two element in jquery 
Javascript :: jest cannot find module 
Javascript :: react create array 
Javascript :: how to target html elements in javascript 
Javascript :: javascript cookies vs session vs local storage 
Javascript :: Creating with the custom hook in react 
Javascript :: get largest no in the array javascript 
Javascript :: concat emoji with text in react js 
Javascript :: js do while loop 
Javascript :: get file extension in javascript 
Javascript :: react useEffect life cycle 
Javascript :: add column sequelize 
Javascript :: best way to clone an object in javascript 
Javascript :: konva line thickness 
Javascript :: select jquery display none 
Javascript :: array==null array.length java script 
Javascript :: string length js 
Javascript :: 1 line password strength checker jquery 
Javascript :: sequelize association alias 
Javascript :: filter function using recursion 
Javascript :: bind method in javascript 
Javascript :: how to use youtube api javascript 
Javascript :: ways of defining object js 
Javascript :: if browser reactjs 
Javascript :: add kendo ui dropdown to angular 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =