Skip to content

React Hook useEffect has missing dependencies: 'onCodeChange', 'roomId', and 'socketRef' #3

Description

@Procoder16

The project was running completely fine until yesterday, but now, whenever I create a new room and join in, it throws an error after 5-10 seconds - "Socket connection failed, try again later."

When I checked the terminal, it had the following error message:

src\components\Editor.js
Line 38:8: React Hook useEffect has missing dependencies: 'onCodeChange', 'roomId', and 'socketRef'. Either include them or remove the dependency array. If 'onCodeChange' changes too often, find the parent component that defines it and wrap that definition in useCallback react-hooks/exhaustive-deps
Line 50:23: The ref value 'socketRef.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy 'socketRef.current' to a variable inside the effect, and use that variable in the cleanup function
react-hooks/exhaustive-deps
Line 52:8: React Hook useEffect has a missing dependency: 'socketRef'. Either include it or remove the dependency array. Mutable values like 'socketRef.current' aren't valid dependencies because mutating them doesn't re-render the component react-hooks/exhaustive-deps

src\pages\EditorPage.js
Line 74:8: React Hook useEffect has missing dependencies: 'location.state?.username', 'reactNavigator', and 'roomId'. Either include them or remove the dependency array react-hooks/exhaustive-deps

src\pages\Home.js
Line 68:25: The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/HEAD/docs/rules/anchor-is-valid.md jsx-a11y/anchor-is-valid

Please suggest a solution to this issue!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions