child client component not updating?
Unanswered
American black bear posted this in #help-forum
American black bearOP
i have this component in a child:
however, when the variable in the parent server componnent changes, the child doesn't seem to rerender.
how can i fix this?
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 componenthowever, when the variable in the parent server componnent changes, the child doesn't seem to rerender.
how can i fix this?
3 Replies
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
American black bearOP
key
?