* Refactor task count * Fixed show page rerender * Less rerenders and way better title and body UX * Finished breaking down activity editor subscriptions * Removed console.log * Last console.log * Fixed bugs and cleaned
28 lines
830 B
TypeScript
28 lines
830 B
TypeScript
import { useEffect } from 'react';
|
|
import { useRecoilState } from 'recoil';
|
|
|
|
import { activityTitleFamilyState } from '@/activities/states/activityTitleFamilyState';
|
|
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
|
|
|
|
export const ActivityTitleEffect = ({ activityId }: { activityId: string }) => {
|
|
const [activityFromStore] = useRecoilState(
|
|
recordStoreFamilyState(activityId),
|
|
);
|
|
|
|
const [activityTitle, setActivityTitle] = useRecoilState(
|
|
activityTitleFamilyState({ activityId }),
|
|
);
|
|
|
|
useEffect(() => {
|
|
if (
|
|
activityTitle === '' &&
|
|
activityFromStore &&
|
|
activityTitle !== activityFromStore.title
|
|
) {
|
|
setActivityTitle(activityFromStore.title);
|
|
}
|
|
}, [activityFromStore, activityTitle, setActivityTitle]);
|
|
|
|
return <></>;
|
|
};
|