-
Notifications
You must be signed in to change notification settings - Fork 0
release 0.15.0 #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
release 0.15.0 #18
Conversation
package.json
Outdated
@@ -1,7 +1,7 @@ | |||
{ | |||
"name": "@connectycube/use-chat", | |||
"description": "A React hook for state management in ConnectyCube-powered chat solutions", | |||
"version": "0.14.4", | |||
"version": "0.15.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.15.0
src/hooks/useBlockList.ts
Outdated
|
||
const addToState = (userId: number): void => { | ||
setState((state) => { | ||
state.add(userId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/hooks/useBlockList.ts
Outdated
|
||
const deleteFromState = (userId: number): void => { | ||
setState((state) => { | ||
state.delete(userId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
src/hooks/useBlockList.ts
Outdated
} | ||
|
||
if (action === BlockAction.ALLOW && !isBlocked(user_id)) { | ||
console.warn("[useChat][useBlockList][update]: user is not blocked"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.warn(`[useChat][useBlockList][update]: user ${user_id} is not blocked`);
src/hooks/useBlockList.ts
Outdated
} | ||
|
||
if (action === BlockAction.DENY && isBlocked(user_id)) { | ||
console.warn("[useChat][useBlockList][update]: user is already blocked"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.warn(`[useChat][useBlockList][update]: user ${user_id} is already blocked`);
CHANGELOG.md
Outdated
|
||
### Features | ||
|
||
- Implemented blockList users API via `useBlockList` hook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
End user does not work directly with useBlockList
, so this can be replaced to
- Implemented Block users API
0.15.0
Features
useBlockList
hook.