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.

DeckSwiper cannot be used inside of a Content Component

See original GitHub issue

Hi! Thanks for trying out NativeBase! Due to the overwhelming requests and issues/questions we ask you to add the following details with your issue.

Please check the existing open/closed issues for a possible duplicate before creating a new issue 😃

Also DO fill out the below form to give us a better idea about your environment and help us debug it quicker. Issues without the required details will mostly be unattended to.

react-native, react and native-base version

“native-base”: “^2.3.1”, “react”: “16.0.0-alpha.12”, “react-native”: “https://github.com/expo/react-native/archive/sdk-20.0.0.tar.gz”,

also using this on expo v20.0.0

Expected behaviour

Using DeckSwiper inside a Content component should render components returned by renderItem prop.

Actual behaviour

Using DeckSwiper inside of a Content component will cause items to not render. The component rendered by renderEmpty prop is fine. No component returned by renderItem prop is ever visible on screen

This is similar behavior to what is observed here: https://github.com/GeekyAnts/NativeBase/issues/369

Steps to reproduce (code snippet or screenshot)

This does not work.

class DummyScreen extends React.Component{
	constructor(props){
		super(props);

		this.blah = this.blah.bind(this)
	}

	blah(item){
		return <TinderCard title='OMG IT RENDERED'></TinderCard>
	}

	render(){

		let data = [];
		data = [1,2,3,4,5];

		return (
			<Container>
				<Header>
					<Left>
						<Button transparent onPress={this.showMenu}>
							<Icon name="menu"></Icon>
						</Button>
					</Left>
					<Body>
						<Title>Tinder</Title>
					</Body>
					<Right></Right>
				</Header>

				<Content>
				<View style={{ flex: 1 }}>
					<DeckSwiper
	            			dataSource={data}
	            			renderItem={this.blah}
	            			renderEmpty={ ()=><Text>GFY</Text> } />
				</View>
				</Content>
			</Container>
		);
	}
}

but if we remove Content component it works

class DummyScreen extends React.Component{
	constructor(props){
		super(props);

		this.blah = this.blah.bind(this)
	}

	blah(item){
		return <TinderCard title='OMG IT RENDERED'></TinderCard>
	}

	render(){

		let data = [];
		data = [1,2,3,4,5];

		return (
			<Container>
				<Header>
					<Left>
						<Button transparent onPress={this.showMenu}>
							<Icon name="menu"></Icon>
						</Button>
					</Left>
					<Body>
						<Title>Tinder</Title>
					</Body>
					<Right></Right>
				</Header>


				<View style={{ flex: 1 }}>
					<DeckSwiper
	            			dataSource={data}
	            			renderItem={this.blah}
	            			renderEmpty={ ()=><Text>GFY</Text> } />
				</View>

			</Container>
		);
	}
}

for the record this does not work either:

<Content style={{ flex: 1 }}>
					<DeckSwiper
	            			dataSource={data}
	            			renderItem={this.blah}
	            			renderEmpty={ ()=><Text>GFY</Text> } />
				</Content>

Screenshot of emulator/device

image

Is the bug present in both ios and android or in any one of them?

haven’t been able to test ios

Any other additional info which would help us debug the issue quicker.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
akhil-gacommented, Sep 29, 2017

adding flex:1 to prop contentContainerStyle solves the issue in android

<Content contentContainerStyle={{ flex: 1 }}>
0reactions
akhil-gacommented, Sep 29, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript:react-native-deck-swiper undefined is not an object ...
I just figured out the problem, that is, I don't need to use the setData() , because it is in the state, just...
Read more >
Components - NativeBase
Each screen can have only one Content component and can be defined anywhere within the Container. Content takes in the whole collection of...
Read more >
Adalo Deck Swiper Component Tutorial - Tinder style swiping
Get 1:1 live consultation and help for Adalo. https://calendly.com/nathancox90/adaloTutorial on how to use the Deck Swiper Component ...
Read more >
react-native-deck-swiper - npm
Awesome tinder like card swiper for react-native. Highly Customizable!. Latest version: 2.0.12, last published: a month ago.
Read more >
Deck Swiper - Adalo Resources
You do not need a paid Adalo plan to use this feature ... Click on the deck swiper component, then click on the...
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