【发布时间】:2019-08-19 20:29:35
【问题描述】:
我有几个一般性的问题想得到答案……我自己研究过:
• firebase 文档在设置 firebase、redux、react 状态时收效甚微。
• 我知道 firebase youtube 频道中包含 React 和 firebase 设置的两部分视频系列,但对将 redux 集成到该生态系统一无所知。
• 此 youtube 视频接近或超过两年,我不知道它们是否仍然适用 (https://www.youtube.com/watch?v=p4XTMvagQ2Q)。
• 我找到了一些与此类设置相关的教程,但在我看来,它们似乎很固执,我不知道这些设置是否最佳或有反模式(https://www.youtube.com/playlist?list=PL4cUxeGkcC9iWstfXntcj8f-dFZ4UtlN3、https://github.com/tiberiuc/redux-react-firebase --straight from资源部分中的 redux 文档,我可能是错的,但它似乎没有被维护,其他人:https://github.com/prescottprue/react-redux-firebase,)。
• 我尝试联系 slack firebase 社区中的#react、#redux、#react-design 频道,但我不相信这些频道正在被使用。我是 firebase 的初学者,现在我正在尝试熟悉这个新数据库……我的问题是:
• 是否建议将此 repo 用于使用 redux 实现 firebase 并做出反应? https://github.com/FirebaseExtended/reactfire#using-the-firebase-js-sdk-in-react
• 我应该像react & firebase 的视频那样跟随firebase API 方法的实现吗?意思是,在组件的生命周期中调用我需要的每个方法,比如说:
componentDidMount() {
firebase.auth().onAuthStateChanged(this.updateAuthState);
}
• and set my default state as such to create the store?:
const defaultState = {
auth: {
isAuth: firebase.auth().currentUser,
},
};
我应该以某种方式将 firebase db 链接到 redux 操作,例如使用 react-redux-firebase 库,还是只是为 firebase 设置一个配置文件,让 redux 独立于它来操作。
最后,我目前正在使用功能的每个组件中导入 firebase,使用 firebase 的正确方法是什么?还是我应该采用另一种方法,例如:https://www.robinwieruch.de/complete-firebase-authentication-react-tutorial/
上面的教程为所有与 firebase 相关的功能创建了一个类,并在需要的地方实例化了该类。
非常感谢您提供的任何帮助,我将不胜感激任何可以帮助我的信息或资源。
【问题讨论】:
标签: reactjs firebase redux react-redux create-react-app