Top-Level API Flashcards

1
Q

React.Component

A

The base class for React Components defined with ES6 classes.

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

React.createClass()

A

Create a component class

params: specification
returns: ReactClass

specification
an object that defines (at least) a render method

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

React.createElement()

A

Creates a ReactElement… either an html tag or a ReactClass. This is equivalent to JSX

params: type[, props[, children …]]
returns: ReactElement

- type
    Either a string for tag name, or an object for ReactClass
- props
    object with the props to pass in
- children
    child elements
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

React.cloneElement()

A

Clones the element with shallow merge for props. Key and ref from original element are preserved.

params: element[, props[, children …]]
returns: ReactElement

- element
    element to clone
- props
    object with the props to pass in
- children
    child elements
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

React.createFactory()

A

Return a function that produces ReactElements of a given type

params: type
returns: factoryFunction

  • type
    HTML string or ReactClass
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

React.isValidElement()

A

Verify that object is ReactElement

params: element
returns: boolean

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

React.DOM

A

Convenience wrappers around React.createElement for DOM components

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

React.PropTypes

A

A list of types that can be used to validate the props being passed in

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

React.Children

A

convenience functions for dealing with the this.props.children opaque data structure

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

React.children.map()

A

Returns an array of the children with fn applied

params: children, fn[, thisArg]
returns: array | null | undefined

Note: if children is a nested object, it will be traversed. fn will not be passed the container

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

React.Children.forEach()

A

Runs the function against all children

params: children, fn[, thisArg]

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

React.Children.count()

A

Counts the children (based oh how many times map fn would be called)

params: children
returns: number

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

React.Children.only()

A

Return the only child in children. Throw otherwise

params: children

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

React.Children.toArray()

A

Return the children data structure as an array. Use to manipulate collections in render methods (e.g reorder or slice)

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

ReactDOM

A

DOM-specific methods that can be used at the top level of an app (to go outside the React model if needed)

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