ReactJS Introduction
ReactJS Introduction
Mendel Rosenblum
Component #1 Babel
Webpack
Component #2 Babel Output
... Bundle.js
Component #N Babel
};
export default ReactAppView;
Doesn't work!
let greeting;
const en = "Hello"; const sp = <b>Hola</b>;
let {useSpanish} = this.prop;
if (useSpanish) {greeting = sp} else {greeting = en};
<div>{greeting}</div>
function MyComponent(props) {
return <div>My name is {props.name}</div>;
}
Or using destructuring...
function MyComponent({name}) {
return <div>My name is {name}</div>;
}
● React Hooks (https://reactjs.org/docs/hooks-intro.html)
○ Add state to stateless components
CS142 Lecture Notes - ReactJS
Communicating between React components
● Passing information from parent to child: Use props (attributes)