FS Module-3
FS Module-3
Manjunath G.S.
Asst. Professor,
Dept. of CS-ICB
Text Books
Web links and Video Lectures (e-Resources):
• https://github.com/vasansr/pro-mern-stack
• https://nptel.ac.in/courses/106106156
• https://archive.nptel.ac.in/courses/106/105/106105084/
• // Parent Component
• const ParentComponent = () => {
• return <ChildComponent name="Alice" />;
• };
• export default ParentComponent;
Accessing Props in Class Components
• import React from 'react';
• class ChildComponent extends React.Component {
• render() {
• return <h1>Hello, {this.props.name}!</h1>;
• }
• }
Prop Types
• import PropTypes from 'prop-types';
• ChildComponent.propTypes = {
• name: PropTypes.string.isRequired,
• };
Passing Functions as Props
• const ChildComponent = ({ onClick }) => {
• return <button onClick={onClick}>Click Me!</button>;
• };