Intro Topics Flashcards

1
Q

const App = () => (

data

)

is the same as…

A

function App() {

return( data )

}

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

Do you have to bind(this) each method in a Class Based Component?

A

No

instead of binding the method in State…

this.increment = this.increment.bind(this)

just make the method an arrow function, and this will bind

increment = () => {}

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

What is the more efficient way of this…

this.setState(prevState => {

return {count: prevState.count + 1}

}

A

Old Way:

this.setState(prevState => {

return {count: prevState.count + 1}

}

New Way:

this.setState(prevState => ({count: prevState.count + 1})

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

New Way of This:

constructor() {

super()

this. state = {
key: value

}

}

A

New Way:

state = {

key: value

}

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

OLD WAY

H1 – {this.state.thingHere} – H1

What’s the new way?

A

New Way

render() {

const { thingHere, otherThing } = this.state

return (

h1– {thingHere} and {otherThing }. – h1 )

Old Way

H1 – {this.state.thingHere} – H1

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

Rename While Deconstructing?

const { thisThing } = this.state

A

Rename doing this -

const {thisThing: renamedThing } = this.state

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

Instead of wrapping in div, and clogging up the DOM, you could use what?

A

–div– –/div–

changed to…

–React.Fragment– –/React.Fragment–

or you could just use empty braces… take the div and just delete the div letters, leave the less than and greater than…

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

How do you add a default prop inside a functional component?

A

props.thingsYourBriningIn accessed in function

after function but before export default XXX

XXX.defaultProps = {

thingsYourBringing: “red”

}

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

How do you add a default prop inside a functional component?

A

props.thingsYourBriningIn accessed in function

after XXX extends Component {

static defaultProps = {

thingsYourBringing: “red”

}

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

What is a Static Method?

Aka Helper Method

A

It’s a method that you can use whether the class was instanciated or not…

Call it on the Class itself, not on the instance…

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

How do you use Prop Types module?

A

import PropTypes from “prop-types”

After XXX Function is completed, before default

XXX.propTypes = {

propName: PropTypes.string

}

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

Most Popular Types to Use with PropTypes Module for React:

import PropTypes from ‘prop-types’;

A

optionalArray: PropTypes.array
optionalBool: PropTypes.bool
optionalFunc: PropTypes.func
optionalNumber: PropTypes.number
optionalObject: PropTypes.object
optionalString: PropTypes.string
optionalSymbol: PropTypes.symbol

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

How do you require a prop?

A

import “PropType” from “prop-types”

XXX.propTypes = {

cardColor: PropTypes.string.isRequired

}

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

Give me an example how you can specifically go through and validate that the prop must one of the options in a function:

A

Example of Prop Must Be One of These:

Card.propTypes = {
cardColor: PropTypes.oneOf([“blue”, “red”])
}

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

What is an enum in JavaScript?

(enumerated type)

A

In computer programming, an enumerated type is a data type consisting of a set of named values called elements, members, enumeral, or enumerators of the type.

In reality Javascript does not support enumerated types, but what you can do is define a global constant object that looks and behaves like an Enum.

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