From 69c083b27d1a2721fdc8ec0e3bf3c012fd91fc96 Mon Sep 17 00:00:00 2001 From: Alexander Blom Date: Mon, 25 Apr 2016 09:43:12 -0700 Subject: [PATCH] Add WebView integration example to cookies example Reviewed By: dmmiller Differential Revision: D3207659 fb-gh-sync-id: f87d70d53de9a8215bb593502368d16251ebb358 fbshipit-source-id: f87d70d53de9a8215bb593502368d16251ebb358 --- Examples/UIExplorer/XHRExampleCookies.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Examples/UIExplorer/XHRExampleCookies.js b/Examples/UIExplorer/XHRExampleCookies.js index c4e710084..d07c7af03 100644 --- a/Examples/UIExplorer/XHRExampleCookies.js +++ b/Examples/UIExplorer/XHRExampleCookies.js @@ -22,6 +22,7 @@ var { Text, TouchableHighlight, View, + WebView, } = ReactNative; var RCTNetworking = require('RCTNetworking'); @@ -45,6 +46,7 @@ class XHRExampleCookies extends React.Component { var url = `https://${domain}/cookies/set?a=${a}&b=${b}`; fetch(url).then((response) => { this.setStatus(`Cookies a=${a}, b=${b} set`); + this.refreshWebview(); }); this.setState({ @@ -59,6 +61,7 @@ class XHRExampleCookies extends React.Component { return response.json(); }).then((data) => { this.setStatus(`Got cookies ${JSON.stringify(data.cookies)} from server`); + this.refreshWebview(); }); this.setStatus('Getting cookies...'); @@ -67,9 +70,14 @@ class XHRExampleCookies extends React.Component { clearCookies() { RCTNetworking.clearCookies((cleared) => { this.setStatus('Cookies cleared, had cookies=' + cleared); + this.refreshWebview(); }); } + refreshWebview() { + this.refs.webview.reload(); + } + setStatus(status: string) { this.setState({status}); } @@ -113,6 +121,18 @@ class XHRExampleCookies extends React.Component { {this.state.status} + + + Refresh Webview + + + ); }