I don't think anyone can actually solve your question but some advices can be given
Use 3 apostrophies at the beginning and at the end to signal a code block. They should be on new lines respective to the code. Also please use the preview option.
For a single line of code you can use a single apostrophe at the beginning and at the end without a new line.
The submitted code is out of context. If this were stackoverflow the question wouldn't even have been approved to be displayed. Please try to recreate a small sample code that vontains everything we might need for an answer if you cannot post the entire code.
Now regarding to your error, that happens when a variable is undefined and you try to access some property for it. In newer versions of JavaScript you can use ? to access properties only when the variable is defined, otherwise you can check with an if(varName) .... Most probably the queries you used didn't find the elements or are not accessible as you expected.
I formatted your code a bit.
I do not know what messageSearch represents and if it can be undefined. If it can then add ? wheneve you try to use one of it's properties. Same for message.
Also if message is an array you should rename it to messages
The error is only a printscreen. You can click the error message and check which line has problems.
From what I can see any variable you should typecheck each variable that deals with a query selector. I can only guess that some of those elements are not always on screen.
Also as a tip you should name anything that is an array with something meaningful, in your case 'messages' should be called 'messageElement' or something while 'message' should be 'messages' or 'messageArray' since the queryAll should return an array.
I don't think anyone can actually solve your question but some advices can be given
?
to access properties only when the variable is defined, otherwise you can check with anif(varName) ...
. Most probably the queries you used didn't find the elements or are not accessible as you expected.Can you just told me where i put the ? in my code?
I formatted your code a bit.
I do not know what
messageSearch
represents and if it can be undefined. If it can then add?
wheneve you try to use one of it's properties. Same formessage
.Also if
message
is an array you should rename it tomessages
//here whole variable
const messages = document.querySelector(".messages");
const message = messages.querySelectorAll(".message");
const messageSearch = document.querySelector("#messages-search");
//and this is complete error massage bro kindly check the error massage
dev-to-uploads.s3.amazonaws.com/up...
The error is only a printscreen. You can click the error message and check which line has problems.
From what I can see any variable you should typecheck each variable that deals with a query selector. I can only guess that some of those elements are not always on screen.
Also as a tip you should name anything that is an array with something meaningful, in your case 'messages' should be called 'messageElement' or something while 'message' should be 'messages' or 'messageArray' since the queryAll should return an array.
//here the line of error but i don't understand why error show
//just check this image bro
dev-to-uploads.s3.amazonaws.com/up...
I checked the code
The problem is that you use querySlectorAll ehich returns an array, while the textContent can be used only on an element
Thanks men!