Skip to content
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

docs(examples): update create-react-app example #4347

Merged
merged 1 commit into from Apr 20, 2022

Conversation

wdwang09
Copy link
Contributor

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behavior

Previous create-react-app example can work normally. However, the useEffect hook will work multiple times when a new message arrives.

I add two console log to show the problem (line 14 and 26 in Gist).

before

Socket.IO callback will change the states, so the React component updates and call useEffect again.

New behavior

I fix this problem by passing a second argument to useEffect (doc). When states change, don't run useEffect again.

after

Other information (e.g. related issues)

Other change: I add the logo and other elements generated by create-react-app.

@darrachequesne darrachequesne merged commit 1f03a44 into socketio:main Apr 20, 2022
@darrachequesne
Copy link
Member

@wdwang09 good catch, thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants