#error #javascript #firebase The error means that it reconise the ref object, but does not reconise the method .on after the ref.

code caused this problme

 blog.ref('blogs').on('value', (snapshot) => {
        const data = snapshot.val();
        for (let key in data) {
            blogData.push(data[key]);
        }
   });

code that fixed the problem

let blogData_firebase = get(blogRef).then((snapshot) => {
        let blogData_temp = snapshot.val();
        return blogData_temp;
    }).catch((error) => {
        console.error(error);
    });
    blogData_firebase.then((value) => {
        setBlogData(value);
    })

better code

useEffect(() => {
        const db = getDatabase();
        let blogRef = ref(db, 'blogs/blogs');
        const offFunction = onValue(blogRef, (snapshot) => {
            const valueObj = snapshot.val();
            const objKeys = Object.keys(valueObj);
            const objArray = objKeys.map((keystring) => {
                const blogObj = valueObj[keystring];
                blogObj.key = keystring;
                return blogObj;
            });
            setBlogData(objArray);
        });
        function cleanup(){
            offFunction();
        }
        return cleanup;
    }, []);