Skip to content

Commit

Permalink
[MTHD-1655] RNMethodElements component (#2)
Browse files Browse the repository at this point in the history
* RNMethodElements component

* PR fixes

* README updated

* Finalize react-native-method-elements

Co-authored-by: Marco del Carmen <[email protected]>
  • Loading branch information
AgustinCastellaG and jmdelcarmen authored May 3, 2022
1 parent 94c480f commit e2689d4
Show file tree
Hide file tree
Showing 7 changed files with 16,789 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Release to NPM
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'

- name: Install NPM packages
run: |
npm install
- name: Run build.
run: |
npm run build
- name: NPM pack
run: |
npm pack
- name: Public to NPM
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ dist

# TernJS port file
.tern-port

# WebStorm
.idea/**
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,49 @@
# react-native-method-elements
react-native-method-elements

[![NPM](https://img.shields.io/npm/v/react-method-elements.svg)](https://www.npmjs.com/package/react-native-method-elements)

## Introduction
Official react native components for Method. See [Method Elements reference](https://docs.methodfi.com/api/elements/intro) to learn more.

## Install

```bash
npm install --save react-native-method-elements

or

yarn install --save react-native-method-elements
```

## Usage

```jsx
import * as React from 'react';
import { RNMethodElements } from 'react-native-method-elements';

const App = () => {
const [token, setToken] = React.useState(null);

React.useEffect(() => {
// Request for an element token from the
// Method API (POST /elements/token)
// through your backend server.
setToken('pk_elem_123456789');
});

if (!token) return null;

return (
<RNMethodElements
env="dev" // (dev / sandbox / production)
token={token}
onOpen={(payload) => console.log('onOpen', payload)}
onSuccess={(payload) => console.log('onSuccess', payload)}
onEvent={(payload) => console.log('onEvent', payload)}
onExit={(payload) => console.log('onExit', payload)}
onError={(payload) => console.log('onError', payload)} />
);
}

export default App;
```
Loading

0 comments on commit e2689d4

Please sign in to comment.