我怎样才能使我的React表始终重置为页面1?

问题描述

我的反应表显示基于用户选择的2或3个不同过滤器的数据。每次更改搜索过滤器并更新表的数据时,该表都会从显示上次查看的页码开始。如何确保每次更改搜索过滤器后,表格始终从第1页开始?

反应表代码

<ReactTable
                    data={this.props.summarydata}
                    columns = {columns}
                    defaultPageSize = {40}
                    pageSizeOptions = {[20,50,100,500]}
                    style={getStyle}
                    loadingText = {"Loading..."}
                    noDataText={"No data found. Please edit search parameters."}
                    minRows={10}
                    resizable={true}
                    prevIoUsText = {"PrevIoUs"}               
                >
                    {(state,filteredData,instance) => {
                        this.ReactTable = state.pageRows.map(post => { return post._original});
                        return(
                            <div>
                                {filteredData()}
                            </div>
                        )
                    }}

                </ReactTable>      

解决方法

按照the docs,您可以像这样将/* ... */ SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT,1); SDL_Window* window = SDL_CreateWindow("Title",SDL_WINDOWPOS_UNDEFINED,Options::width,Options::height,video_flags); // Create one SDL context per thread std::vector<SDL_GLContext> threads_glcontexts(globalThreadPool.get_num_threads()); for(auto& t_ctx: threads_glcontexts) { t_ctx = SDL_GL_CreateContext(window); } // Main thread context SDL_GLContext main_glcontext = SDL_GL_CreateContext(window); // Setup one context per thread // // This function only returns when all threads // in the pool have executed the given function. std::mutex mtx; globalThreadPool.run_in_every_pool_thread([&](unsigned thread_idx) { std::lock_guard<std::mutex> lock(mtx); // ← ↓ WORKINING CODE SDL_GL_MakeCurrent(window,threads_glcontexts[thread_idx]); }); /* ... */ 属性添加到表格选项对象中,

autoResetPage
<ReactTable
                    data={this.props.summarydata}
                    columns = {columns}
// This one!
                    autoResetPage={true}
                    defaultPageSize = {40}
                    pageSizeOptions = {[20,50,100,500]}
                    style={getStyle}
                    loadingText = {"Loading..."}
                    noDataText={"No data found. Please edit search parameters."}
                    minRows={10}
                    resizable={true}
                    previousText = {"Previous"}               
                >
                    {(state,filteredData,instance) => {
                        this.ReactTable = state.pageRows.map(post => { return post._original});
                        return(
                            <div>
                                {filteredData()}
                            </div>
                        )
                    }}

                </ReactTable>