@stakekit/use-inject-provider
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

React hook for injecting a provider into a react-native-webview

Utility hook for injecting EIP-1193 provider in react-native-webview

npm install @steakwallet/use-inject-provider

or

yarn add @steakwallet/use-inject-provider

or

pnpm add @steakwallet/use-inject-provider

Example:

import React, { useRef } from 'react';
import { StyleSheet } from 'react-native';
import WebView from 'react-native-webview';
import { useInjectProvider } from '@steakwallet/use-inject-provider';

// Some EIP1193Provider thats managed by wallet
const provider = new Provider();

export const WebViewStake = () => {
  const webViewRef = useRef<WebView>(null);

  const { injectedJavaScript, onMessage } = useInjectProvider({
    webViewRef,
    provider,
  });

  return (
    <WebView
      ref={webViewRef}
      source={{ uri: 'https://stakek.it' }}
      onMessage={onMessage}
      injectedJavaScript={injectedJavaScript}
      style={styles.container}
      cacheEnabled={false}
    />
  );
};

const styles = StyleSheet.create({
  container: { flex: 1 },
});

Package Sidebar

Install

npm i @stakekit/use-inject-provider

Weekly Downloads

14

Version

0.0.1

License

MIT

Unpacked Size

173 kB

Total Files

14

Last publish

Collaborators

  • stefan_stakekit
  • notaphplover
  • philipmzdb
  • jdomingos
  • petar-omni