Skip to content

Instantly share code, notes, and snippets.

@whichsteveyp
Created July 6, 2017 02:01
Show Gist options
  • Save whichsteveyp/6a46a9cd6724a6a4d1b856be8a10ea03 to your computer and use it in GitHub Desktop.
Save whichsteveyp/6a46a9cd6724a6a4d1b856be8a10ea03 to your computer and use it in GitHub Desktop.
Stephen vs Promises
import React from 'react';
import Component from './Component.jsx';
export default class App extends React.Component {
render() {
return <Component options={{ autoplay: true }}>
{(status, video) => {
// this error is being caught in the promise in component render, even though
// I am only trying to catch errors from the class' method using a util file
console.log(status);
}}
</Component>;
}
}
import React from 'react';
export default class Component extends React.Component {
componentWillMount() {
this.initNetflixVideoLibStuff();
}
render() {
const { status, video } = this.state;
const { children } = this.props;
return children(
status,
video,
preferProxy // this is not defined in scope properly, and will explode
);
}
initNetflixVideoLibStuff(); {
const { options } = this.props;
return VideoUtils.init(options);
.then(video => this.setState({ video }))
.catch(status => this.setState({ status }); // this catches the explode in render...for fun?
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment