react-native-step-indicator icon indicating copy to clipboard operation
react-native-step-indicator copied to clipboard

Navigate between componenets

Open chevulkar opened this issue 6 years ago • 9 comments

I have used external components my code looks like this
import StepOne from '../StepOne'; import StepTwo from '../StepTwo'; import StepThree from '../StepThree'; const PAGES = [{"id":1,"page":<StepOne></StepOne>},{"id":2,"page":<StepTwo></StepTwo>},{"id":3,"page":<StepThree></StepThree>}]; Now the problem here is I need to manually trigger the transitions between pages I tried putting onPress={()=>this.viewpager.goToPage(2)} in my StepOne component but it dosen't work I have no idea is this even possible as i didn't find any example of the same. Can someone please help me with this.

chevulkar avatar Jan 14 '19 13:01 chevulkar

Did you see this example ? https://github.com/24ark/react-native-step-indicator/blob/master/example/HorizontalStepIndicatorExample.js It should help you https://github.com/24ark/react-native-step-indicator/blob/a8b5aa41d56d5c4795a8edccc694959ed1c4ab90/example/HorizontalStepIndicatorExample.js#L143-L144 https://github.com/24ark/react-native-step-indicator/blob/a8b5aa41d56d5c4795a8edccc694959ed1c4ab90/example/HorizontalStepIndicatorExample.js#L124 https://github.com/24ark/react-native-step-indicator/blob/a8b5aa41d56d5c4795a8edccc694959ed1c4ab90/example/HorizontalStepIndicatorExample.js#L133

Drakoun avatar Jan 28 '19 14:01 Drakoun

same problem with me

jhontech32 avatar Feb 01 '19 04:02 jhontech32

I solved the problem. I passed an function as a to each screen and on click of any button on that screen I triggered that function on main screen and changed the page see the example below

import StepOne from '../StepOne'; import StepTwo from '../StepTwo'; import StepThree from '../StepThree'; nextPage = (page) => { this.viewPager.setPage(page) } const PAGES = [{"id":1,"page":<StepOne nextPage={this.nextPage}></StepOne>},{"id":2,"page":<StepTwo nextPage={this.nextPage}></StepTwo>},{"id":3,"page":<StepThree nextPage={this.nextPage}></StepThree>}];

and from StepTwo I simply called onPress={()=>this.props.nextPage(2)}

chevulkar avatar Feb 01 '19 08:02 chevulkar

owh, i see but there u do simply called from component <StepTwo/> or in StepTwo file ?

jhontech32 avatar Feb 01 '19 10:02 jhontech32

I have passed nextPage as a props to the pages, and from second pages I simply call the function

chevulkar avatar Feb 01 '19 10:02 chevulkar

may i see your code, i still get error :((

jhontech32 avatar Feb 02 '19 02:02 jhontech32

Post your code here ill look into it

chevulkar avatar Feb 02 '19 06:02 chevulkar

@chevulkar your solution creates an error that this.nextPage is undefined

angielle avatar Mar 03 '19 17:03 angielle

Please share your code.

chevulkar avatar Mar 05 '19 06:03 chevulkar