-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathuri.js
More file actions
29 lines (24 loc) · 930 Bytes
/
uri.js
File metadata and controls
29 lines (24 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import React from 'react';
import { WebView } from 'react-native-webview';
import { action } from '@storybook/addon-actions';
import { text } from '@storybook/addon-knobs';
import InjectableWebView from './components/InjectableWebView';
export const basic = () => <WebView source={{ uri: 'https://www.youtube.com/embed/dQw4w9WgXcQ' }} />;
export const onMessage = () => (
<WebView source={{ uri: require('./onMessage.html') }} onMessage={action(text('Text', 'onMessage'))} />
);
const js = `
const button = document.getElementById('button')
button.removeEventListener('click', onClick)
onClick = () => window.alert('Hello from iframe!')
button.addEventListener('click', onClick)
window.alert('click the button')
`;
export const inject = () => (
<InjectableWebView
onMessage={action(text('Text', 'onMessage'))}
source={{ uri: require('./onMessage.html') }}
title="test"
script={text('script', js)}
/>
);