Next Generation Javascript Flashcards
Component?
Core building block of React
What is the Root of a React Component Tree
App
What does each Component need to return?
Each component needs to return / render some JSX code
What is JSX code?
It defines what HTML-like code React renders
What are the two types of React components?
Functional and Class Based
What is a Functional Component?
×
const cmp = ( ) => {return
some JSX
};
×
What is a Class-Based Component?
×
class cmp extends Component
Render ( ) {
Return
some JSX
;
}
};
×
What are Props?
Arguments passed to a component function
{props.title}
What are two ways of creating variables?
Let -> variable value
Const -> Variable that doesn’t change
What is an arrow function?
const myfunc = (arguments) => {function body}
How to write an arrow function with one argument?
const printMyName = name => console.log(name);
printMyName(‘Frank’);
An arrow function with two arguments
const printMyName = (name, age) => {
console.log(name, age);
}
printMyName(‘Frank’, ‘60’);
Arrow function shortcut if only returning one value
const mutliply = number => number*2;
console.log(multiply(2));
How to export a function
Export
person.js
const person = {name: ‘Max’};
export default person;
Import
import person from ‘./person’;
import prs from ‘./person’;
Export multiple functions
utility.js
Export
export const clean = () => { };
export const basedata= 10j;
Import
import {basedata} from ‘./utility’;
import {clean as cl} from ‘./utility’;
import * as bundled from ‘./utility’;