Web UIKit v3.0 Migration Guide
Major breaking changes
{
[componentName: string]: ReactComponent
} {
[componentName: string]: (props: componentProps) => ReactNode
} Deprecated functions
const [isSubmitting, setIsSubmitting] = useState(false) const onSubmit = async () => { try { setIsSubmitting(true) // callback code } finally { setIsSubmitting(false); } }
const [ref, element] = useElement() <div ref={ref} />const elementRef = useRef<HTMLDivElement | null>(null) // element is elementRef.current <div ref={elementRef} />
const followStatus = useFollowStatus(sourceUserId) const isFollowNone = followStatus === 'none' const isFollowAccepted = followStatus === 'accepted' const isFollowPending = followStatus === 'pending'const follow = UserRepository.Relationship.follow const followAccept = UserRepository.Relationship.acceptMyFollower const followDecline = UserRepository.Relationship.declineMyFollower const deleteFollower = UserRepository.Relationship.unfollow
const isLiked = !!( comment && comment.myReactions && comment.myReactions.includes(LIKE_REACTION_KEY) ); const totalLikes = comment?.reactions[LIKE_REACTION_KEY] || 0; const handleToggleLike = async () => { if (comment == null) return; try { if (!isLiked) { await ReactionRepository.addReaction('comment', comment.commentId, LIKE_REACTION_KEY); onLikeSuccess?.(comment); } else { await ReactionRepository.removeReaction('comment', comment.commentId, LIKE_REACTION_KEY); onUnlikeSuccess?.(comment); } } catch (_error) { console.error("Can't toggle like", _error); } };use useCommunityMembersCollection and useCommunityModeratorsCollection insteadcurrentMember = const currentMember = members.find((member) => member.userId === currentUserId); const isCommunityModerator = isModerator(currentMember?.roles); const hasModeratorPermissions = (isCommunityMember(currentMember) && isCommunityModerator) || isModerator(user?.roles) || isAdmin(user?.roles); for members use useCommunityMembersCollection instead for permission related use useCommunityPermission insteadfunction isPostLikedByMe(post?: Amity.Post) { if (post == null || post.myReactions?.length === 0) return false; return post?.myReactions?.includes(LIKE_REACTION_KEY); } const [isActive, setIsActive] = useState(isPostLikedByMe(post)); useEffect(() => { setIsActive(isPostLikedByMe(post)); }, [post?.myReactions]); const handleToggleLike = async () => { if (post == null) return; if (!isActive) { await ReactionRepository.addReaction('post', post.postId, LIKE_REACTION_KEY); onLikeSuccess?.(post); setIsActive(!isActive); } else { await ReactionRepository.removeReaction('post', post.postId, LIKE_REACTION_KEY); onUnlikeSuccess?.(post); setIsActive(!isActive); } };use node promisify instead or const promise = new Promise((resolve, reject) => { fn(function callback(data) => { resolve(data) }) })export function stripUndefinedValues<T extends object>(obj: T): Partial<T> { const result: Partial<T> = {}; Object.entries(obj).forEach(([key, value]) => { if (value !== undefined) { result[key as keyof T] = value; } }); return result; }
Breaking changes functions
Last updated
Was this helpful?