snack-sdk add module

#1

Hi there I am trying to install react-native-apper on a snack input but it does work can someone help me understand how it works I have been through the docs buy nothing
this is the code
initial code

const INITIAL_CODE = `
import React, { Component } from 'react';
import {Button} from 'react-native-paper';
import { Text, View, StyleSheet } from 'react-native';
import { Constants } from 'expo';
export default class App extends Component {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.paragraph}>
          Change code in the editor and watch it change on your phone!
          Save to get a shareable url. You get a new url each time you save.
        </Text>
      </View>
    );
  }
}
const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    paddingTop: Constants.statusBarHeight,
    backgroundColor: '#ecf0f1',
  },
  paragraph: {
    margin: 24,
    fontSize: 18,
    fontWeight: 'bold',
    textAlign: 'center',
    color: '#34495e',
  },
});
`;

session code

    const code = INITIAL_CODE;
    this._snack = new SnackSession({
      files: {
        "app.js": { type: "CODE", contents: code }
      },
      dependencies: { "react-native-paper": "2.11.1" },
      sessionId: Math.random()
        .toString(36)
        .substr(2, 8),
      sdkVersion: "30.0.0"
    });
#2

Ok after having reading the source code I have found the solution I think the docs just need to be update. this is the solution

dependencies: {
    "react-native-paper": {
        version: "2.11.1"
    }
},

instead of

dependencies: { "react-native-paper": "2.11.1" },

as written in the docs. I will make a pull request with an updated version of the docs

closed #3

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.