React Flashcards

1
Q

how to define a html/css class in react

A

className=”string”;

className={ expression }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

basic render function?

A

return (

<div></div>

);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

import react and hooks

A

import React, {useEffect, useState, createRef, etc.. } from “react”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

set up a basic state variable and setter

A

const [varName, setVarName] = useState();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

set a default state when setting up a state variable

A

const [varName, setVarName] = useState(‘default val’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

update a state variable using the setter

A

setVarName(‘new value’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

set up a useEffect handler function

A

useEffect(() => {
actionHandler();
});
//or: },[list, of, functions, to, watch]
use [] so it only activates on first mount

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

create a Ref to a dom element

functionally

A

let textInput = useRef(null);

using:
{
props.setEmail(textInput.current.value)
}}

in render:

ref={textInput} />

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what does ‘useEffect return’ equal?

A

useEffect return is mostly equal to componentWillUnmount

How well did you know this?
1
Not at all
2
3
4
5
Perfectly