Firebase服务仅显示React应用程序的空白页

时间:2020-06-15 12:02:58

标签: reactjs firebase-hosting firebase-tools

您好,基本上,每当我使用npm start在本地运行网站时,它都会显示没有任何问题。

我现在已经尝试使用firebase serve进行尝试,但是可悲的是,它只会弹出空白页面,而后台没有任何错误。

但是,URL路径更新后,将显示默认的404页面。

我在公用文件夹中有index.html文件和404.html。我有一个名为“ src”的单独文件夹,其中包含React组件。我还尝试将src文件夹添加到公共文件夹中,但没有实际更改。

有人可以让我知道我是否在这里错过什么吗?

index.html在公用文件夹中

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <meta name="theme-color" content="#000000">
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json">
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <title>React App</title>
  </head>
  <body>
    <noscript>
      You need to enable JavaScript to run this app.
    </noscript>
    <div id="root"></div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/js/materialize.min.js"></script>
  </body>
</html>

src文件夹中的index.js

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
import { createStore, applyMiddleware, compose } from 'redux'
import rootReducer from './store/reducers/rootReducer'
import { Provider } from 'react-redux'
import thunk from 'redux-thunk'
import { reduxFirestore, getFirestore } from 'redux-firestore';
import { reactReduxFirebase, getFirebase } from 'react-redux-firebase';
import fbConfig from './config/fbConfig'

const store = createStore(rootReducer,
  compose(
    applyMiddleware(thunk.withExtraArgument({getFirebase, getFirestore})),
    reactReduxFirebase(fbConfig, {userProfile: 'users', useFirestoreForProfile: true, attachAuthIsReady: true}),
    reduxFirestore(fbConfig) // redux bindings for firestore
  )
);

store.firebaseAuthIsReady.then(() => {
  ReactDOM.render(<Provider store={store}><App /></Provider>, document.getElementById('root'));
  registerServiceWorker();
});

1 个答案:

答案 0 :(得分:0)

您的浏览器控制台中有什么?类似于 %PUBLIC_URL% 的“URI 格式错误”?