leecade / leecade/react-native-swiper

Doesn't work: Dynamic render swiper page (show/hide).

Open
#847 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
10.5k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

I have used child components as each swipe page.
// for eg
// child components
export default component1 Site extends Component {
render(){
return <Text>Component1</Text>
}
}

// parent component (Having swiper)
<Swiper
ref={el => this.contentRef(el)}
scrollEnabled={true}
loop={false}
showsButtons={false}
showsPagination={false}
<Component1 />
<Component2 />
<Component3 />
<Component4 />
<Component5 />
</Swiper>

Now I have to show dynamic show/hide pages based on i had values like

  • showComponent1 == true
  • showComponent2 == false
  • showComponent3 == false
  • showComponent4 == true

when I applied it as following,
<Swiper
ref={el => this.contentRef(el)}
scrollEnabled={true}
loop={false}
showsButtons={false}
showsPagination={false}
{ showComponent1 && <Component1 />}
{ showComponent2 && <Component2 />}
{ showComponent3 && <Component3 />}
{ showComponent4 && <Component4 />}
<Component5 />
</Swiper>

Problem:

  • It still display component2 and component3 in swiper. I cant use array or map for rendering pages in swiper because each are different components

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the conditional child rendering shown in the issue with react-native-swiper, then inspect how Swiper discovers and renders its child components. Confirm the behavior with showComponent2 and showComponent3 false; done means those pages no longer appear while the enabled pages remain available.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react, react-native
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.