I have a state named chats
in which i am storing all messages from firebase and i'm trying to render it in app. but it does not render
here is my component's state:
const [chats, setChats] = useState([]);
I am bringing messages in UseEffect hook to get it on running of app
useEffect(() => {
let merged_uid = uid_merger(current_user.id, chat_user.uid);
database()
.ref('/')
.child(`chats/${merged_uid}`)
.on('child_added', (msgs) => {
console.log(msgs);
chats.push(msgs.val());
setChats(chats);
});
}, []);
but id does not render.