-
+ const space = useContext(SpacesContext);
+ const inputRef = useRef
(null);
+
+ const handleSubmit = (e: FormEvent) => {
+ e.preventDefault();
+
+ if (!space || !setIsVisible) return;
+
+ space.updateProfileData({ name: inputRef.current?.value, color: getRandomColor() });
+ setIsVisible(false);
+ };
+
+ return (
+
+
-}
\ No newline at end of file
+ );
+};
diff --git a/demo/src/hooks/useMembers.ts b/demo/src/hooks/useMembers.ts
index dd5a220b..dce3f940 100644
--- a/demo/src/hooks/useMembers.ts
+++ b/demo/src/hooks/useMembers.ts
@@ -49,13 +49,12 @@ export const useMembers: () => Partial<{ self?: Member; others: Member[]; member
if (areMembers(initMembers)) {
setMembers(initMembers);
setOthers(membersToOthers(initMembers, initSelf));
- }
+ }
+ space.subscribe('update', handler);
};
init();
- console.log('update!')
- space.subscribe('update', handler);
-
+
return () => {
space.unsubscribe('update', handler);
};