promises Flashcards
What are the three states a Promise can be in?
pending - The initial state of a promise.
fulfilled - The state of a promise representing a successful operation.
rejected - The state of a promise representing a failed operation.
How do you handle the fulfillment of a Promise?
use the .then method and then you pass in an anonymous arrow functions
How do you handle the rejection of a Promise?
by calling the .catch( ) method, and take a function as its argument
What doesfetch()return?
it return a Promise
What is the default request method used by fetch()?
.get()
How do you specify the request method (GET, POST, etc.) when calling fetch?
add a second parameter with request method
When does React call a component’s componentDidMount method?
invoked immediately after a component is mounted or inserted into the tree. If you need to load data from a remote endpoint, this a good place to instantiate the network request.(after first successful render)
Name three React.Component lifecycle methods.
mounting, updating, unmounting
How do you pass data to a child component?
by using this.state.(__) in the parent component then this.prop.data in the child component