basic Flashcards
how do you call a component called person with parameters name and age?
ReactDOM.render(‘’,
document.querySelector(‘#p1’));
como se declara la funcion Person?
function Person(props) { return ( <div> <h1>{props.name}</h1> Age : {props.age} </div> ); }
what is the major React component that you render through ReactDOM.render() method?
how do you import the react module
import React from ‘react’;
functional component definition?
declare through a function and also called stateless, dumb or presentational. const cmp = () => { return <div>some JSX</div> }
class-base component definition?
define through a class. stateful, smart and containers. class Cmp extends Component { render() { return <div> some JSX </div>; } }
create a functional component that takes name and age as arguments?
import React from ‘react’;
const person = (props) => { return <p>I'm {props.name} and I am {props.age} years old!</p>; };
export default person;
create a functional component that works like this:
Reading
const person = (props) => { return <div> <p>I'm {props.name} and I am {props.age} years old!</p> <p>And my hobby is {props.children}</p> </div> };
export default person;
create a functional component that works like this:
Reading with the parentesis
const person = (props) => { return ( <div> <p>I'm {props.name} and I am {props.age} years old!</p> <p>And my hobby is {props.children}</p> </div> ) };
export default person;
add an array of persons to the state property of the App class
class App extends Component { state = { persons: [ {name : 'Max', age: 28}, {name : 'Manu', age: 29}, {name : 'Stephanie', age: 26}
] } ...
props triggers an UI update? and state?
yes. yes too
where do you declare the state?
as a property in a class, specially App class
what is this inside to a non ES6 function referring to ?
not to the class but to something internal I am not sure. but if you use arrow functions it will always refer to the class.
in a class definition do you separate method declarations and poperties with ;?
no.
basic instruction for rendering a JSX element
ReactDOM.render(<h1>Hello world</h1>, document.getElementById(‘app’)); there’s a