Created
July 6, 2017 02:01
-
-
Save whichsteveyp/6a46a9cd6724a6a4d1b856be8a10ea03 to your computer and use it in GitHub Desktop.
Stephen vs Promises
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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