我正在做一个React项目。尝试按注册或登录按钮g时,我立即收到此错误,似乎在项目中抱怨很多文件。它的真正含义是什么?我该如何解决?
这是错误:
错误:对象作为React子对象无效(发现:SyntaxError: JSON.parse:JSON数据第1行第1行的意外字符)。 如果要渲染子级集合,请改用数组。
' WITH WARNINGS (NO NEED TO CLOSE ACTION QUERIES) DoCmd.OpenQuery myAppendQuery DoCmd.OpenQuery myUpdateQuery ' WITHOUT WARNINGS CurrentDb.Execute myAppendQuery CurrentDb.Execute myUpdateQuery
这是登录代码的一部分,在错误中被引用:
in p (at register.jsx:68)
in div (at register.jsx:65)
in p (at login.jsx:64)
in div (at login.jsx:62)
in LoginPage (at App.tsx:61)
in Route (at App.tsx:60)
in Switch (at App.tsx:53)
in div (at App.tsx:41)
in Router (created by BrowserRouter)
in BrowserRouter (at App.tsx:40)
in header (at App.tsx:39)
in div (at App.tsx:38)
in App (at src/index.js:8)
这是App.tsx文件:
renderRedirect() {
render() {
const { user, submitted } = this.state;
return (
<div className="col-md-6 col-md-offset-3"> // line 62
{this.renderRedirect()}
<p>{this.state.errorMessage}</p> // line 64
<h2>Login</h2> if (this.props.loggedIn) {
return <Redirect to="/" />;
}
}
这是index.js文件:
public render() {
return (
<div className="App">
<header className="App-header">
<Router>
<div> // line 41
<ul>
<Link to="/" className="btn btn-link"> Game </Link>
{this.state.loggedIn ? null : ( <Link to="/register" className="btn btn-link"> Register </Link> )}
{this.state.loggedIn ? null : ( <Link to="/login" className="btn btn-link"> Login </Link> )}
{this.state.loggedIn ? (
<Link to="/logout" className="btn btn-link"> Logout </Link>
) : null}
<Link to="/highscores" className="btn btn-link"> Highscores </Link>
</ul>
<hr />
<Switch> // line 53
<Route exact path="/">
<GameView loggedIn={this.state.loggedIn} />
</Route>
<Route path="/register">
<Register />
</Route>
<Route path="/login"> // line 60
<Login
loggedIn={this.state.loggedIn}
setLoggedIn={this.setLoggedIn}
/>
</Route>
<Route path="/logout">
<Logout setLoggedIn={this.setLoggedIn} />
</Route>
<Route path="/highscores">
<HighscorePage />
</Route>
</Switch>
</div>
</Router>
</header>
</div>
);
}
这是register.jsx文件的一部分:
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
//import { App } from "./App";
import * as serviceWorker from './serviceWorker';
ReactDOM.render(<App />, document.getElementById('root')); // line 8
serviceWorker.unregister();