2017-05-12 2 views
0

내가 가진 몇 가지 문제를 사용하지 않고 오류 라우터 반응하고 : 그에서 오는 될 수있다특별히에도 반응 라우터-DOM과 그것을

warning.js?8a56:36 Warning: Failed prop type: The prop `history` is marked as required in `Router`, but its value is `undefined`. 
    in Router 
printWarning @ warning.js?8a56:36 
warning @ warning.js?8a56:60 
checkReactTypeSpec @ checkReactTypeSpec.js?d08c:80 
validatePropTypes @ ReactElementValidator.js?a599:161 
createElement @ ReactElementValidator.js?a599:213 
(anonymous) @ app.jsx?0ec4:14 
(anonymous) @ bundle.js:1289 
__webpack_require__ @ bundle.js:20 
(anonymous) @ bundle.js:66 
(anonymous) @ bundle.js:69 
Router.js?a4aa:31 Uncaught TypeError: Cannot read property 'location' of undefined 
    at new Router (eval at <anonymous> (bundle.js:794), <anonymous>:39:52) 
    at eval (eval at <anonymous> (bundle.js:2335), <anonymous>:295:18) 
    at measureLifeCyclePerf (eval at <anonymous> (bundle.js:2335), <anonymous>:75:12) 
    at ReactCompositeComponentWrapper._constructComponentWithoutOwner (eval at <anonymous> (bundle.js:2335), <anonymous>:294:16) 
    at ReactCompositeComponentWrapper._constructComponent (eval at <anonymous> (bundle.js:2335), <anonymous>:280:21) 
    at ReactCompositeComponentWrapper.mountComponent (eval at <anonymous> (bundle.js:2335), <anonymous>:188:21) 
    at Object.mountComponent (eval at <anonymous> (bundle.js:387), <anonymous>:46:35) 
    at ReactCompositeComponentWrapper.performInitialMount (eval at <anonymous> (bundle.js:2335), <anonymous>:371:34) 
    at ReactCompositeComponentWrapper.mountComponent (eval at <anonymous> (bundle.js:2335), <anonymous>:258:21) 
    at Object.mountComponent (eval at <anonymous> (bundle.js:387), <anonymous>:46:35) 

궁금했다. 컴파일 된 파일에서 완전히 제거했습니다.

그래서

import ReactDom from 'react-dom'; 
const Error =() => <h1>Error</h1>; 


ReactDom.render(
    <Error/> 
    , 
    document.getElementById('react-app')); 

을 app.js : 그 성가신 오류가 오는 곳에서

난 그냥 알아 내가 가능한 한 단순하게 수정 된 주요 반응 파일을 컴파일 웹팩을 사용하여 나는 기본적으로 react-router-dom을 더 이상 사용하지 않지만 어떤 이유로 든 오류가 거기에 머물러 있습니다.

웹팩 coniguration :

module.exports = { 
    entry: './client/src/app.js', 
    devtool: '#eval-source-map', 
    output: { 
     path: __dirname + '/client/dist/', 
     filename: 'bundle.js' 
    }, 
    module: { 
     loaders: [ 
      { 
       test: /\.js$/, 
       exclude: /(node_modules|app-server.js)/, 
       loader: 'babel-loader' 
      } 
     ] 
    } 
}; 

답변

0

내가 당신을 제안 :

  1. 삭제 빌드 *는 .js 파일.
  2. package.json 파일의 확인 번호가 react-router-dom이 아닌지 확인하십시오.
  3. 그렇다면 npm uninstall --save react-router-domnode_modules 디렉토리를 제거하고 패키지를 다시 설치하고 빌드를 확인하십시오.

또한 browserify과 테스트를위한 코드를 만들 시도 할 수 있습니다 :

npm install -g browserify 
browserify ./client/src/app.js -o ./client/dist/bundle.js -t [ babelify --presets [ es2015 react ] ] -v 
+0

은 이미 당신의 제안을 모두 노력했다. 나는 지금 바꿀 것인가를 확인하기 위해 browserify를 할 것이지만 분명히 나는 ​​babelify 모듈을 필요로한다. –

+0

이 경우에는'babel-preset-es2015','babel-preset-react' 및'babelify'를 당신의 dev 의존성에 설치해야합니다. –

+0

완료. 나는 당신의 접근 방법도 시도했다. 나는 같은 오류가있다. –