# V2 Migration Guide

_Steps to migrate from the legacy Evervault React Native package to @evervault/react-native v2._

## Install react-native-webview

The `react-native-webview` package is now a peer dependency and will need to be installed as well.

```bash
## Using npm
npm install react-native-webview

## Using yarn
yarn add react-native-webview

## Using Expo
npx expo install react-native-webview
```

## Update your imports

The package name has been updated to `@evervault/react-native`.

```diff
- import { EvervaultProvider } from '@evervault/evervault-react-native';
+ import { EvervaultProvider } from '@evervault/react-native';
```

## Remove top-level function calls

In the previous version, you could call `init()` and `encrypt()` directly from the package.

These functions are no longer exposed at the top level. Instead:

- Initializing the SDK is now done via the [{'<EvervaultProvider />'}](/sdks/react-native#evervault-provider) component.
- Encrypting data is now done via the `encrypt()` method returned from the [`useEvervault`](/sdks/react-native#use-evervault) hook.

```diff
- import { init } from '@evervault/evervault-react-native';
+ import { EvervaultProvider } from '@evervault/react-native';

  function App() {
-   useEffect(() => {
-     init('team_id', 'app_id');
-   }, []);

    return (
+     <EvervaultProvider teamId="team_id" appId="app_id">
        <YourApp />
+     </EvervaultProvider>
    );
  }
```

```diff
- import { encrypt } from '@evervault/evervault-react-native';
+ import { useEvervault } from '@evervault/react-native';

  function App() {
+   const { encrypt } = useEvervault();

    async function handleEncrypt() {
      const encrypted = await encrypt('data');
    }
  }
```

### Update Card props

In the previous version, you could pass styles to the [{'<Card />'}](/sdks/react-native#card) component via the `style` prop.

The Card component no longer renders a View, so you should move the styles to a parent or child View.

```diff
- <Card style={{ padding: 16 }} />
+ <View style={{ padding: 16 }}>
+   <Card />
+ </View>
```

The previous version also accepted `acceptedBrands` via the `config` prop. This has been moved top-level:

```diff
- <Card config={{ acceptedBrands: ['visa', 'mastercard'] }} />
+ <Card acceptedBrands={['visa', 'mastercard']} />
```

Finally, the `initialValue` prop has been renamed to `defaultValues`:

```diff
- <Card initialValue={{ name: 'John Doe' }} />
+ <Card defaultValues={{ name: 'John Doe' }} />
```

### Rename Card.CVC to Card.Cvc

The `Card.CVC` prop has been renamed to `Card.Cvc`.

```diff
- <Card.CVC placeholder="CVC" />
+ <Card.Cvc placeholder="CVC" />
```

