Error: Invalid hook call. guys please helpme

import React, { useState ,useEffect} from 'react'
import "./Chat.css"
import { Avatar ,  IconButton } from '@material-ui/core'
import MoreVertIcon from '@material-ui/icons/MoreVert';
import SearchOutlinedIcon from '@material-ui/icons/SearchOutlined';
import AttachFileIcon from '@material-ui/icons/AttachFile';
import EmojiEmotionsOutlinedIcon from '@material-ui/icons/EmojiEmotionsOutlined';
import MicIcon from '@material-ui/icons/Mic';
import { useParams } from "react-router-dom";
import db from './firebase';
function Chat(props) {
    const [input, setInput] = useState('')
    const [seed, setSeed] = useState('');
    const { roomId } = useParams();
    const [roomName, setRoomName] =useState("")
    useEffect(() => {
      if(roomId) {
        .onSnapshot(snapshot =>(
    }, [roomId] )
    useEffect(() => {
        setSeed(Math.floor(Math.random() * 5000));
      }, [])

    const sendMessage = (event) => {
    return <div className="chat"> 

      <div className="chat__header">
      <Avatar src={`${seed}.svg`} />
      <div className="chat__headerInfo">
      <p> last message....</p>

      <div className="chat__headerRight">
      <SearchOutlinedIcon />

      <div className="chat__body">
      <p className={`chat__message ${true &&
      <span className="chat__name">Ashu</span>
      Hey guys
      <span className ="chat__timestamp">2:52pm;

      <div className="chat__footer">
      <input value={input} 
      onChange={(event) => setInput(}
      placeholder="Type a message..."
      type="text" />
      <button onClick="{sendMessage}" type="submit">Send a message</button>

export default Chat

Please help!!!!!. whenever I tries to use {useparams}
I fails and anerror is displayed:
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app
    See for tips about how to debug and fix this problem.

Please help me How to debug it

57 thoughts on “Error: Invalid hook call. guys please helpme”