A user enters the app on a Today page, but if there is no “Today” ready for that given user I want to redirect them to a page where they can create the “Today”.
I’m currently loading a “TodayCell” on the “TodayPage”, should I chuck the navigate in the empty block of that cell? Or would it maybe be better to actually just perform the GraphQL call on the TodayPage itself?
I suppose that when there is no “Today”, your TodayCell will render export const Empty = () => <div>Empty</div>. If so, you can simply replace <div>Empty</div> by <Redirect to={routes.createTodayPage()} />
Don’t forget to import { Redirect, routes } from '@redwoodjs/router' at the top of your cell.
I know this is an old thread but I came across this when getting the error “Empty(…): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.”. Thought I’d add a comment in case others have the same issue.
I was trying to use navigate() within the empty component but it didn’t like that I wasn’t rendering anything. Navigating then returning an empty fragment worked a bit better but I still got a console warning (“Cannot update during an existing state transition (such as within render). Render methods should be a pure function of props and state.”).
I’d forgotten about so this was a great help - thanks!