[英]I am trying to convert my existing react app with next.js. Is it a right thing to do?
我们已经使用 firebase auth 和 solr DB 在 react-redux 中创建了项目。
下面是我们应用程序的当前文件夹结构。
--src
--actions
--assets
--components
--controllers
--firebase
--reducers
--utils
--app.js
现在,要将应用程序转换为下一个 js,我在依赖项中添加了下一个 js 并更改了脚本如下
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
现在,我在“src”文件夹中创建了目录“pages”并添加了“index.js”hello world react程序来测试下一个js,它通过运行脚本“npm run dev”来工作
因此,我将所有文件夹从“controllers”复制到“pages”文件夹并尝试访问静态页面“about”
在这里,我遇到了以下错误,
有时这个错误:
Firebase:名为“[DEFAULT]”的 Firebase 应用已经存在(app/duplicate-app)。
并在重新加载一段时间后在同一页面上出现此错误:
FirebaseError:projectId 必须是 FirebaseApp.options 中的字符串
What other things to do more to convert existing react app to next.js?
我在 Next.js 和 React Native 中多次看到这个 firebase 错误。 我认为它与渲染或其他东西有关,但这是解决方案:
firebase.js
import firebase from 'firebase/app';
import 'firebase/firestore';
import 'firebase/auth';
let config = {
// your config
};
export default !firebase.apps.length
? firebase.initializeApp(config)
: firebase.app();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.