Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 198 prop type and docs #199

Merged
merged 7 commits into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion PlaidLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ PlaidLink.propTypes = {
oauthStateId: PropTypes.string,

// Underlying component to render
component: PropTypes.func,
component: PropTypes.elementType,

// Props for underlying component
componentProps: PropTypes.object,
Expand Down
55 changes: 28 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

In your react-native project directory:

```
```sh
npm install --save react-native-plaid-link-sdk
```

Expand All @@ -14,13 +14,13 @@ When upgrading from a previous major version of this library, see the notes [her

Add `Plaid` to your project’s Podfile as follows (likely located at `ios/Podfile`). The latest version is ![version](https://img.shields.io/cocoapods/v/Plaid).

```
```sh
pod 'Plaid', '~> <insert latest version>'
```

Then install your cocoapods dependencies:

```
```sh
(cd ios && pod install)
```

Expand All @@ -32,7 +32,7 @@ That's it if using a recent react-native version with [autolinking](https://gith

If using a version of react-native without [autolinking](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md) support, then you will need to:

```
```sh
react-native link react-native-plaid-link-sdk
```

Expand Down Expand Up @@ -63,10 +63,11 @@ followed by

```groovy
dependencies {
...
// ...
implementation project(':react-native-plaid-link-sdk')
implementation 'com.plaid.link:sdk-core:<insert latest version>'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:<insert at least version 4.x>'
}
```

5. Go to `android/settings.gradle`
Expand All @@ -91,17 +92,17 @@ project(':react-native-plaid-link-sdk').projectDir = new File(rootProject.projec
To initialize Plaid Link, you will need to first create a `link_token` at [/link/token/create](https://plaid.com/docs/#create-link-token).
After creating a link_token, you'll need to pass it into your app and use it to launch Link:

```
```javascript
import { Text } from 'react-native';
import PlaidLink from 'react-native-plaid-link-sdk';

const MyPlaidComponent = () => {
return (
<PlaidLink
// Replace any of the following <#VARIABLE#>s according to your setup,
// for details see https://plaid.com/docs/quickstart/#client-side-link-configuration
token={<#GENERATED_LINK_TOKEN#>}
// Replace any of the following <#VARIABLE#>s according to your setup,
// for details see https://plaid.com/docs/quickstart/#client-side-link-configuration

token = {"<#GENERATED_LINK_TOKEN#>"}
onSuccess={data => console.log('success: ', data)}
onExit={data => console.log('exit: ', data)}
>
Expand All @@ -119,23 +120,23 @@ If you configured your `link_token` with one or more European country codes and

The React Native Plaid module emits `onEvent` events throughout the account linking process — see [details here](https://plaid.com/docs/#onevent-callback). To receive these events in your React Native app, wrap the `PlaidLink` react component with the following in order to listen for those events:

```
```javascript
import React from 'react';
import { Text, NativeEventEmitter, NativeModules } from 'react-native';
import { Text, NativeEventEmitter, NativeModules, Platform } from 'react-native';

class PlaidEventContainer extends React.Component {

componentDidMount() {
const emitter = new NativeEventEmitter(Platform.OS === 'ios' ? NativeModules.RNLinksdk : NativeModules.PlaidAndroid);
this._listener = emitter.addListener('onEvent', (e) => console.log(e));
}

componentWillUnmount() {
if (this._listener) {
this._listener.remove();
}
}

render() {
return (
<PlaidLink
Expand All @@ -152,22 +153,22 @@ class PlaidEventContainer extends React.Component {

You can also use the `usePlaidEmitter` hook in react functional components:

```
```javascript
usePlaidEmitter((event) => {
console.log(event)
})
```

### Customizing the PlaidLink component

By default, `PlaidLink` renders a `TouchableOpacity` component. You may override the component used by passing `component` and `componentProps`. For example:
By default, `PlaidLink` renders a `TouchableOpacity` component. You may override the component used by passing `component` that accepts an `onPress` callback prop and `componentProps`. For example:

```
<PlaidLink
token = {<#GENERATED_LINK_TOKEN#>}
component= {Button}
componentProps = {{title: 'Add Account'}}
onSuccess = {(result) => {console.log('Success: ', result)}}
onError = {(result) => {console.log('Error: ', result)}}
>
```jsx
<PlaidLink
token = {"<#GENERATED_LINK_TOKEN#>"}
component= {Button}
componentProps = {{title: 'Add Account'}}
onSuccess = {(result) => {console.log('Success: ', result)}}
onError = {(result) => {console.log('Error: ', result)}}
>
```