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

[Typescript error] Swipelist not showing #17

Open
ZeroCool00 opened this issue Nov 14, 2018 · 2 comments
Open

[Typescript error] Swipelist not showing #17

ZeroCool00 opened this issue Nov 14, 2018 · 2 comments

Comments

@ZeroCool00
Copy link

ZeroCool00 commented Nov 14, 2018

i just implement this library, i follow each step, but list is not showing. if i render something else it will render successfully, but swipelist not working. is this because of this error?

screen shot 2018-11-14 at 3 41 51 pm

here is the complete code in case if i missing something:

import React from 'react';
import createReactClass from 'create-react-class';
import { View, Text, StyleSheet } from 'react-native';
import {Icon} from 'native-base';
import SwipeList from 'react-native-smooth-swipe-list';


const RowList = createReactClass({

    componentDidMount() {
      this.rowData = this.props.array.map(this.constructRowData);
    },

  constructRowData(item) {
      return {
          id: item,
          rowView: this.getRowView(item),
          rightSubView: this.getRemoveButton(),
          style: styles.rowFront //optional but recommended to style your rows
      };
  },
      
  getRowView(item) {
      console.log("Item>> ", item)
      return (
        <View style={styles.rowFront}>
            <Text>{`I am  a SwipeListView`}</Text>
        </View>
      );
  },

  getRemoveButton() {
    return(
      <View style={styles.rowBack}>
          <Icon name="close" style={styles.iconClose} type="FontAwesome" />
          <Text style={{ color: '#FFF', fontFamily: 'Gilroy-extrabold', marginLeft: 5}}>Remove</Text>
      </View>
    );
  },

  render() {
    return <SwipeList rowData={this.rowData}  />;
  }

});

const styles = StyleSheet.create({
  rowBack: {
    backgroundColor: "#5E368E",
    alignItems: 'center',
    justifyContent: 'center',
    flexDirection: 'row'
  },
  iconClose: {
    color: '#FFF',
    fontSize: 24,
    fontWeight: 'bold',
  },
  rowFront: {
    borderBottomColor: '#EEE',
    borderBottomWidth: 1,
    paddingHorizontal: 100,
    paddingVertical: 15,
  }
});

export default RowList;
import RowList from './rowList';
class Watch extends Component {
  state = {
    array: [1,2,3,4,5]
  }

  render() {
    const { flexOne } = styles;
    const {array} = this.state;
    return (
      <View style={flexOne}>
          { array && array.length > 0 ? <RowList array={array} /> : <EmptyView title="watch" text="stories" />}
      </View>
    );
  }
}

version:

"react-native-smooth-swipe-list": "^1.4.7"

@andrewgrewell
Copy link
Contributor

I haven't got the project setup to work with Typescript yet.
For now you should be able to create an index.d.ts file somewhere in your project and add

declare module 'react-native-smooth-swipe-list';

Which will get past the Typescript errors, but Typescript also will not know anything about the module.

If you or someone else wants to add Typescript support that would be great!

@andrewgrewell andrewgrewell changed the title Swipelist not showing [Typescript error] Swipelist not showing Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants