Keep current page index when changing state?
See original GitHub issueI’m using Swiper and on the second page there is a textinput. When the user changes the text in the textinput I call setState()
to update the state with the changes. The problem is, when the state reloads, Swipe automatically shows the first page not the second page. I’ve tried to set the index
prop on Swipe but it doesn’t seem to work correctly. Any way to keep the current page when updating the state?
<TextInput
onChangeText={(name) => {this.setState({name})}}
value={this.state.name} />
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:11
Top Results From Across the Web
Maintaining GridView current page index after navigating ...
I am looking for sample code snippet on the Server Side on how to specify the page index to set the GridView after...
Read more >How can I set pageIndex of paginator and it can update itself?
First page is 0 and current page is 1, the paginator view display 11-20 of 400 . I set the pageIndex to initial...
Read more >Create and update an index - Microsoft Support
To edit or format an index entry, change the text inside the quotation marks. To update the index, click the index, and then...
Read more >page.info() - DataTables
This method provides information about the table's paging state, and information about the number of records in the table (both total and in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
my way might not work for your use cases but this is what i did. i set a state variable in my constructor:
this.state = { someOtherStuff: 2, cameraIndex: 1 };
set the index in the swiper to this variableindex={this.state.cameraIndex}
then when i change the state, i make sure to set this state variableself.setState({someOtherStuff: val, cameraIndex: 0})
feels a bit hacky but its working for me for nownow I use
_onMomentumScrollEnd(e, state, context)
reset currentindex
, it works.regards.