Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set click menu reload the page with next/router #3937

Closed
jyjin opened this issue Mar 5, 2018 · 2 comments
Closed

How to set click menu reload the page with next/router #3937

jyjin opened this issue Mar 5, 2018 · 2 comments

Comments

@jyjin
Copy link

jyjin commented Mar 5, 2018

Code:

import Router from 'next/router'
import { Scrollbars } from 'react-custom-scrollbars'

export default class ChildrenMenus extends React.Component {
    render() {
        return (
            <div style={{flex:1}}>
                <Scrollbars>
                <List>
                    { this.props.menus.map((item,_index)=>{
                        let _st={}
                        if(_index==this.props.selected){
                            _st.style={
                                backgroundColor: "rgba(0, 0, 0, 0.2)"
                            }
                        }
                        _st.onTouchTap=()=>{
                            Router.push(item.href)
                        }
                        return <ListItem key={_index} primaryText={item.text[this.props.local]} {..._st}/>
                    }) }
                </List>
                </Scrollbars>
            </div>
        )
    }
}

when I visit /system/home, it get the home page correctly. But I have many content in the home page, including table with page and charts and so on. I want to click home page menu to reload this page, and I tried add timestamp query like ?t=timestamp to the url , but not worked. So what shall I do?

@timneutkens
Copy link
Member

Based on your description I can't follow what you want to do. If you want to force page reloads just use window.location.href = url.

Please follow the issue template 🙏

@jyjin
Copy link
Author

jyjin commented Mar 5, 2018

Location.href will reload all page resource. I has two leval menu, and each menu has one page. But some pages I have the 'inner page', this 'inner page' just by state coding, they not really a page. No matter it is outer page or inner page, they are from the same route, just by different state. When I was in inner page, and want to back outer page, I just want to click the menu for that. But they are same route, I still in inner page.
And of course I can use location.href or window.reload to fix that, but it reload all the page resource, I observe when route change, route.push() is not reload all the resource, but if do with location.href or winodw.reload it will and there a few second blank page on my screen.

@lock lock bot locked as resolved and limited conversation to collaborators May 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants