Conversation
DaveLomber
reviewed
Feb 26, 2025
package.json
Outdated
| "name": "@connectycube/use-chat", | ||
| "description": "A React hook for state management in ConnectyCube-powered chat solutions", | ||
| "version": "0.14.4", | ||
| "version": "0.15.1", |
DaveLomber
reviewed
Feb 26, 2025
src/hooks/useBlockList.ts
Outdated
|
|
||
| const addToState = (userId: number): void => { | ||
| setState((state) => { | ||
| state.add(userId); |
Contributor
There was a problem hiding this comment.
React state should be treated as immutable. In your code, you're directly mutating the existing Set by calling its .add() method, and then returning the same reference. This can lead to issues because React relies on detecting changes via new object references. If the state reference remains unchanged, React might not trigger a re-render.
Let's replaced to
const addToState = (userId: number): void => {
setState(prevState => {
const newState = new Set(prevState);
newState.add(userId);
return newState;
});
};
This ensures that you are not mutating the previous state directly and that React will properly update the component when the state changes.
DaveLomber
reviewed
Feb 26, 2025
src/hooks/useBlockList.ts
Outdated
|
|
||
| const deleteFromState = (userId: number): void => { | ||
| setState((state) => { | ||
| state.delete(userId); |
DaveLomber
reviewed
Feb 26, 2025
src/hooks/useBlockList.ts
Outdated
| } | ||
|
|
||
| if (action === BlockAction.ALLOW && !isBlocked(user_id)) { | ||
| console.warn("[useChat][useBlockList][update]: user is not blocked"); |
Contributor
There was a problem hiding this comment.
console.warn(`[useChat][useBlockList][update]: user ${user_id} is not blocked`);
DaveLomber
reviewed
Feb 26, 2025
src/hooks/useBlockList.ts
Outdated
| } | ||
|
|
||
| if (action === BlockAction.DENY && isBlocked(user_id)) { | ||
| console.warn("[useChat][useBlockList][update]: user is already blocked"); |
Contributor
There was a problem hiding this comment.
console.warn(`[useChat][useBlockList][update]: user ${user_id} is already blocked`);
DaveLomber
reviewed
Feb 26, 2025
CHANGELOG.md
Outdated
|
|
||
| ### Features | ||
|
|
||
| - Implemented blockList users API via `useBlockList` hook. |
Contributor
There was a problem hiding this comment.
End user does not work directly with useBlockList , so this can be replaced to
- Implemented Block users API
DaveLomber
approved these changes
Feb 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
0.15.0
Features
useBlockListhook.