我有一个带旋转幻灯片的仪表板,每个幻灯片在Bldgs中都有一个相应的标签.两者Dashboard.js并Bldgs.js有孩子我App.js.
当用户点击特定幻灯片A时Dashboard.js,Dashboard需要告知App.js以便在路由到时App可以告诉显示Bldgs.js标签.ABldgs
我相信,我传递正确的索引值从Dashboard最高App和向下Bldgs.但是,我的App.js文件中引发了一个错误:
Uncaught TypeError: Cannot read property 'push' of undefined
在我开始将handleClick()函数传递给Dashboard组件之前,我的代码工作正常.
Index.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
import injectTapEventPlugin from 'react-tap-event-plugin';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import { BrowserRouter as Router } from …Run Code Online (Sandbox Code Playgroud) 我目前正在我的cpe类中的一个实验室工作,我们必须创建一个简单的程序,它从.txt文件中扫描字符串并将它们打印到不同的.txt文件.到目前为止,我已经绘制了基本程序,但是我的异常一直在扔,尽管我有所有必要的文件.任何人都可以帮我调试吗?
import java.io.*;
import java.util.*;
public class FileIO {
public static void main(String args[]) {
try {
File input = new File("input");
File output = new File("output");
Scanner sc = new Scanner(input);
PrintWriter printer = new PrintWriter(output);
while(sc.hasNextLine()) {
String s = sc.nextLine();
printer.write(s);
}
}
catch(FileNotFoundException e) {
System.err.println("File not found. Please scan in new file.");
}
}
}
Run Code Online (Sandbox Code Playgroud) 我知道当应用程序进入非活动状态时,SpriteKit已处理暂停游戏,但我正在尝试做的是在应用程序重新进入活动状态时添加SKLabelNode"点击以恢复".现在它正在调用我的函数并暂停游戏,但文本没有显示.
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. …Run Code Online (Sandbox Code Playgroud) 我最初使用hashHistory来自,react-router并使用来以编程方式导航我的React应用this.props.history.push()。但是随着HashRouter从react-router-dom软件包的使用开始,this.props.history.push()现在会引发Cannot read property 'push' of undefined错误。
HashRouter现在如何以编程方式导航?
ReactDOM.render(
<Provider store={store}>
<MuiThemeProvider>
<HashRouter>
<div>
<Route exact path="/" component={App} />
<Route path="/landing" component={Landing} />
</div>
</HashRouter>
</MuiThemeProvider>
</Provider>,
document.getElementById('root'));
Run Code Online (Sandbox Code Playgroud)
App.js的渲染功能
render() {
return (
<div className="App">
...
<div>
<Collapse isOpened={this.state.activeForm === 1}>
<SignUpForm />
</Collapse>
<Collapse isOpened={this.state.activeForm === 2}>
<SignInForm />
</Collapse>
...
</div>
);
}
Run Code Online (Sandbox Code Playgroud)
SignUpForm.js中正在调用的函数.push()
handleSubmit(e) {
...
this.props.history.push('/landing');
...
}
Run Code Online (Sandbox Code Playgroud)