Next.js Discord

Discord Forum

child client component not updating?

Unanswered
American black bear posted this in #help-forum
Open in Discord
Avatar
American black bearOP
i have this component in a child:
export function JournalList({startJournals, startPage = 1}) {
  const {data: session} = useSession();
  const [journals, setJournals] = useState(startJournals);
  // ...
and startJournals is defined by a variable in the parent server component
however, when the variable in the parent server componnent changes, the child doesn't seem to rerender.
how can i fix this?

3 Replies

Avatar
joulev & fuma pray for Schneider
this is just how react works. startJournals is used as the initial value for a state so is only used during mount, not rerenders. you have to force remount by using key
Avatar
American black bearOP
key?
Avatar
joulev & fuma pray for Schneider