What component lifecycle to use to do something before render()?

前端 未结 4 446
悲&欢浪女
悲&欢浪女 2020-12-04 02:48

I need to check whether some props (from redux store) is an empty object or not. If it is empty, I want the page to redirect to another page and not bother to call ren

4条回答
  •  离开以前
    2020-12-04 03:05

    You could use the Redirect component of react-router within render.

    import { Redirect } from 'react-router'
    render(){
    
     (checkIfObjectEmpty)?:
    
    }
    

提交回复
热议问题