- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我有一个日记应用程序,我正在尝试用 React Native 编写它。我是个新手,但我读到的所有内容都表明我所做的事情应该有效。基本上,我将一些数据放入 redux Action 类中并尝试编写它。但我不断得到,
未定义不是一个对象“评估'_firebase2.default.database.ref')
我已经仔细阅读了我多次使用的教程中的“将新数据保存到 firebase”部分,但我只是不明白我做错了什么。这是我的代码,
import firebase from 'firebase';
import { Actions } from 'react-native-router-flux';
import { DIARY_UPDATE, DIARY_SAVED, DIARY_FETCH_SUCCESS } from './types';
export const diaryUpdate = ({ prop, value }) => ({
type: DIARY_UPDATE,
payload: { prop, value }
});
export const diarySave = ({ date, location, activity, satisfaction,
amenities, note }) => {
const { currentUser } = firebase.auth();
return (dispatch) => {
firebase.datebase.ref(`Users/${currentUser.uid}/diary`)
.push({ date, location, activity, satisfaction, amenities, note })
.then(() => {
dispatch({ type: DIARY_SAVED });
Actions.dashboard({ type: 'Replace' });
});
};
};
export const diaryFetch = () => {
const { currentUser } = firebase.auth();
return (dispatch) => {
firebase.datebase.ref(`Users/${currentUser.uid}/diary`)
.on('value', snapshot => {
dispatch({ type: DIARY_FETCH_SUCCESS, payload: snapshot.val() });
});
};
};
我有控制台记录这些值,以检查传递的内容是否有问题。
这是我正在初始化 firebase 的 App.js。我应该提到 firebase 的身份验证功能运行良好!
import React, { Component } from 'react';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import firebase from 'firebase';
import reduxThunk from 'redux-thunk';
import reducers from './src/reducers';
import Router from './src/Router';
export default class App extends Component {
componentWillMount() {
if (!firebase.apps.length) {
const fconfig = {
apiKey: 'AIzaSyAkYD2TodRFEiln8JZPp2DtDyfIwIr654U',
authDomain: 'yourhappyplace-6c049.firebaseapp.com',
databaseURL: 'https://yourhappyplace-6c049.firebaseio.com',
projectId: 'yourhappyplace-6c049',
storageBucket: 'yourhappyplace-6c049.appspot.com',
messagingSenderId: '634967086167'
};
firebase.initializeApp(fconfig);
}
}
render() {
//Create redux store with redux thunk middleware
const happyStore = createStore(reducers, {}, applyMiddleware(reduxThunk));
return (
<Provider store={happyStore}>
<Router />
</Provider>
);
}
}
有人能看出我到底做错了什么吗?谢谢!
最佳答案
要访问 FirebaseDatabase 实例,请在 FirebaseApp
实例上调用 database()
方法。
拼写为database()
并加上括号:
firebase.database().ref(...)
关于javascript - 无法从 Firebase 保存或获取数据(React Native 和 Firebase 的新增功能),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52369856/
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
1. 新增用户 复制代码代码如下: mysql>insert into mysql.user(Host,User,Password) values(&quo
本文实例讲述了PHP操作redis实现的分页列表,新增,删除功能封装类与用法。分享给大家供大家参考,具体如下: <?php/* * redis 分页数据类库 */class redisP
在我的场景中,我必须使用类来添加 div ,这可以使用 onClick 函数轻松解决,但我需要它来完成我的任务,.click(function() 不适用于新元素,javascript/jquery
本文主要介绍了vue+elementui通用弹窗的实现(新增+编辑),分享给大家,具体如下: 组件模板 ?
例如: 修改(列名前 要有column关键字) ALTER TABLE [USER] ALTER column [
复制代码 代码如下: //连接localhost:27017 $conn = new Mongo(); //连接远程主机默认端口 $conn = new Mong
我正在关注这个guideline对于 Maven 插件,我添加了以下内容: org.apache.maven.plugins maven-release-plugin 2.5.3 ma
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
在新的 Lucene 4.4.0 版本中,近实时管理器 (org.apache.lucene.search.NRTManage) 已被 ControlledRealTimeReopenThread 取
抱歉,我现在正在编程中,但是我正在学习中,请帮助我。我被困在这个问题上。这是我的第一个应用程序,在likke帮助下需要完成所有工作。 我收到此错误:类型'_InternalLinkedHashMap'
从下图中我们可以看出,使用 XCode 11 构建的 iOS 13 的新呈现样式使导航栏的高度(56 高)与“全屏”呈现的导航栏(44 高)不同。 这里的问题是我的应用程序使用的是自定义的书面导航栏,
在 EGit 2.3 中,他们根据他们的发布文档添加了非快进 merge 功能 "Support git merge --no-ff as an EGit preference." http://wi
IntelliJ IDEA 2020.3.3的新错误修复程序已发布!您可以使用工具箱应用程序从IDE内部更新到新版本,也可以点击下方链接下载。 idea激活码 下载IntelliJ IDEA 2
据小米手环官微消息,小米手环 5 固件版本更新至 1.0.2.46 版本,另外小米运动 APP 也更新至了 4.8.0 版本。 此次更新使得小米手环 5 实现了 24 小时睡眠监测,对于上夜班
我在最新的 IntelliJ Idea 中得到以下提示: Not registered via @EnableConfigurationProperties or marked as Spring c
我有一个 UserModel,用于生产。我想添加一个 bool 属性(isRegistered)。对于已经在我的平台上的人们,我希望这个新属性是真实的。对于新用户,我希望它默认为 false。 如何将
CSS 1、CSS 2、CSS 2.1 和 CSS 3:每个版本的哪些 CSS 属性和选择器不同?我在谷歌上搜索了很多,但没有找到任何列表? 我需要每个版本所支持的属性和选择器的列表,但有差异。 最佳
为什么? Web 应用程序(.NET Framework)和核心 Web 应用程序(.NET Core)都面向 AnyCPU 平台。 这是一个错误还是这样做有什么值(value)? 我在 Window
我是一名优秀的程序员,十分优秀!