Skip to content

Instantly share code, notes, and snippets.

@dhrrgn
Created August 7, 2016 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhrrgn/6212ae915e3c3dfd00b3ed71c27c682f to your computer and use it in GitHub Desktop.
Save dhrrgn/6212ae915e3c3dfd00b3ed71c27c682f to your computer and use it in GitHub Desktop.
import React, { Component, PropTypes } from 'react';
import { WebView } from 'react-native';
import CookieManager from 'react-native-cookies';
export default class extends Component {
static propTypes = {
clearCookies: PropTypes.bool,
};
static defaultProps = {
clearCookies: true,
};
constructor(props) {
super(props);
this.state = {
url: null,
};
}
componentWillMount() {
if (this.props.clearCookies) {
CookieManager.clearAll(() => {
this.setState({url: this.props.url});
});
} else {
this.setState({url: this.props.url});
}
}
render() {
return (
<WebView
{...this.props}
source={{uri: this.state.url}}
startInLoadingState={true}
/>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment