在reactJS应用程序中的dev控制台中发出警告

时间:2018-02-20 11:49:50

标签: javascript reactjs

在我的反应JS应用程序中,我在控制台中收到了此警告:

browser.js?26d3:49 Warning: <BrowserRouter> ignores the history prop. To use a custom history, use `import { Router }` instead of `import { BrowserRouter as Router }`.

我是这样做的:

import {BrowserRouter as Router, hashHistory, Switch, NavLink, Route} from "react-router-dom";


render() {
    const {t} = this.props;
    return (
        <Provider store={store}>
            <AppContainer>
                <Router history={createHistory}>
                    <div>

如果我在警告中执行上述更改,则应用程序不再运行并抛出错误

其中一个看起来像这样:

AppContainer.dev.js?cd84:95 TypeError: Cannot read property 'pathname' of undefined

我该如何解决这个问题?

提前致谢

1 个答案:

答案 0 :(得分:1)

这里有两个选项:

答:使用Sub MergeExcelFiles() Dim fnameList, fnameCurFile As Variant Dim countFiles, countSheets As Integer Dim wksCurSheet As Worksheet Dim wbkCurBook, wbkSrcBook As Workbook fnameList = Application.GetOpenFilename(FileFilter:="Microsoft Excel Workbooks (*.xls;*.xlsx;*.xlsm),*.xls;*.xlsx;*.xlsm", Title:="Choose Excel files to merge", MultiSelect:=True) If (vbBoolean <> VarType(fnameList)) Then If (UBound(fnameList) > 0) Then countFiles = 0 countSheets = 0 Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Set wbkCurBook = ActiveWorkbook For Each fnameCurFile In fnameList countFiles = countFiles + 1 Set wbkSrcBook = Workbooks.Open(filename:=fnameCurFile) For Each wksCurSheet In wbkSrcBook.Sheets countSheets = countSheets + 1 wksCurSheet.Copy After:=wbkCurBook.Sheets(wbkCurBook.Sheets.Count) Next wbkSrcBook.Close SaveChanges:=False Next Application.ScreenUpdating = True Application.Calculation = xlCalculationAutomatic MsgBox "Procesed " & countFiles & " files" & vbCrLf & "Merged " & countSheets & " worksheets", Title:="Merge Excel files" End If Else MsgBox "No files selected", Title:="Merge Excel files" End If End Sub ,只需不会将历史传递给它:

BrowserRouter

或者

<Router>

B:使用import {BrowserRouter, hashHistory, Switch, NavLink, Route} from "react-router-dom"; ... <BrowserRouter> 并传递实例化的历史记录对象:

Router