question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Example is overly complex and hard to understand

See original GitHub issue

Is this a bug report, a feature request, or a question?

Feature request

Example is overly complex

Thanks for a great package. Can I suggest adding a simple and easy to understand example?

npx react-native init carousel-simple-example
cd carousel-simple-example
npm install react-native-snap-carousel

App.js

import React from 'react';
import {
  Text, 
  View,
  SafeAreaView } from 'react-native';
import Carousel from 'react-native-snap-carousel';

export default class App extends React.Component {
 
    constructor(props){
        super(props);
        this.state = {
          activeIndex:0,
          carouselItems: [
          {
              title:"Item 1",
              text: "Text 1",
          },
          {
              title:"Item 2",
              text: "Text 2",
          },
          {
              title:"Item 3",
              text: "Text 3",
          },
          {
              title:"Item 4",
              text: "Text 4",
          },
          {
              title:"Item 5",
              text: "Text 5",
          },
        ]
      }
    }

    _renderItem({item,index}){
        return (
          <View style={{
              backgroundColor:'floralwhite',
              borderRadius: 5,
              height: 250,
              padding: 50,
              marginLeft: 25,
              marginRight: 25, }}>
            <Text style={{fontSize: 30}}>{item.title}</Text>
            <Text>{item.text}</Text>
          </View>

        )
    }

    render() {
        return (
          <SafeAreaView style={{flex: 1, backgroundColor:'rebeccapurple', paddingTop: 50, }}>
            <View style={{ flex: 1, flexDirection:'row', justifyContent: 'center', }}>
                <Carousel
                  layout={"default"}
                  ref={ref => this.carousel = ref}
                  data={this.state.carouselItems}
                  sliderWidth={300}
                  itemWidth={300}
                  renderItem={this._renderItem}
                  onSnapToItem = { index => this.setState({activeIndex:index}) } />
            </View>
          </SafeAreaView>
        );
    }
}

Running on a device

npx react-native run-android npx react-native run-ios

First item Second item

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
FEhaocommented, Mar 4, 2020

can’t agree more

1reaction
bd-arccommented, Mar 6, 2020

@ViktorMS Unfortunately I’m faced with the following error when trying to play your example in the browser: Device: Unable to resolve module 'module://expo-constants.js'. This happens with both the iOS and Android previews.

Do you know where this could come from?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Complicated and difficult to understand - Macmillan Dictionary
complicated · difficult to do, deal with, or understand, especially because of involving a lot of different processes or aspects ; difficult ·...
Read more >
Overly complex definition and meaning - Collins Dictionary
Overly complex definition: Overly means more than is normal, ... that is complex has many different parts, and is therefore often difficult to...
Read more >
Complexity Bias: Why We Prefer Complicated to Simple
We need complexity even while we crave simplicity… Some complexity is desirable. When things are too simple, they are also viewed as dull...
Read more >
Superiority Complex: Understanding It, Traits, Treatment and ...
A superiority complex is a behavior that suggests a person believes they're somehow superior to others. People with this complex often have ...
Read more >
Personality Disorders | Johns Hopkins Medicine
People with a personality disorder display more rigid thinking and reacting behaviors that ... Examples of odd/eccentric (Cluster A) personality disorders.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found