程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了TypeError:u.indexOf 不是 Reactjs 和 Firebase 的函数大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决TypeError:u.indexOf 不是 Reactjs 和 Firebase 的函数?

开发过程中遇到TypeError:u.indexOf 不是 Reactjs 和 Firebase 的函数的问题如何解决?下面主要结合日常开发的经验,给出你关于TypeError:u.indexOf 不是 Reactjs 和 Firebase 的函数的解决方法建议,希望对你解决TypeError:u.indexOf 不是 Reactjs 和 Firebase 的函数有所启发或帮助;

我在学习本教程时遇到以下错误 https://www.youtube.com/watch?v=QiTq5WrWoJw&t=8176s

我在将我的个人消息连接到我的 firebase 应用程序时遇到问题。我在控制台中的错误集中在以下代码上。

我正在尝试在 firebase 内的单个“房间”中发送消息,以便在每个房间内包含具有独特消息的房间集合。

function ChaTinput(chAnnelname,chAnnelID) {

    const [input,seTinput] = useState('');

    const sendmessage = (E) => {
        e.preventDefault(); //prevents refresh of the page

        if(!chAnnelID) {
            return false;
        }
            db.collection("rooms").doc(chAnnelID).collection("messages").add({
              message: input,timestamp: firebase.firestore.FIEldValue.servertimestamp(),user: 'DanIEl Peters',userImage:'https://wallpapercave.com/wp/j8Sd6Uv.jpg',});

            seTinput('');
    };

    return (
        <ChaTinputContainer>
            <form>
                <input value={input} onChange={(E) => seTinput(e.target.value)} placeholder= {`message #${ChAnnelnamE}`} />
                <button hIDden type='submit' onClick={sendmessagE}>
                    SEND
                </button>
            </form>



        </ChaTinputContainer>
    )
}

export default ChaTinput;

我尝试了不@R_777_11197@的 redux 和 firebase,看看是否是这个问题,但问题显然没有解决。任何指导都会很棒!

解决方法

我刚刚遇到了这个问题,最终我的“错误”是我试图使用数字 ID 作为 firestore 文档键。

所以这个给出了 u.indexOf is not a function 错误:

      let ref = db.collection(`userPreferences/${userID}/venues`).doc(venue.id);

这个工作在哪里:

  let ref = db.collection(`userPreferences/${userID}/venues`).doc(`${venue.iD}`);

我只是用引号将第二个括起来以使其成为字符串。 希望能挽救某人的一天!

大佬总结

以上是大佬教程为你收集整理的TypeError:u.indexOf 不是 Reactjs 和 Firebase 的函数全部内容,希望文章能够帮你解决TypeError:u.indexOf 不是 Reactjs 和 Firebase 的函数所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。