/ / प्रतिक्रिया-राउटर लिंक काम नहीं कर रहा है - अभिक्रिया, प्रतिक्रिया-राउटर, प्रतिक्रिया-रिडक्स

प्रतिक्रिया-राउटर लिंक काम नहीं कर रहा है - प्रतिक्रिया, प्रतिक्रिया-राउटर, प्रतिक्रिया-redux

मैं प्रतिक्रिया में एक सरल लिंक बनाने की कोशिश कर रहा हूं। यहाँ कोड है:

    import React from "react";
import { Link }  from "react-router";
class List extends React.Component{
render() {
return (
<div>
<p>please choose from repository below.</p>
<ul>
<li><Link to={"/react"}>React</Link></li>
</ul>
</div>
);
}
}

export default List;

मेरा पैकेज यहाँ है। जेसन:

"dependencies": {
"chance": "^1.0.9",
"history": "^4.6.1",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-router": "^4.1.1",
"react-router-dom": "^4.1.1",
"superagent": "^3.5.2"

मैंने अपना कोड चलाने के लिए निम्नलिखित आदेश का उपयोग किया:

webpack-देव-सर्वर

bundle.js:1004 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it"s defined in. Check the render method of `List`.
in List (created by Route)
in Route
in div
in Router (created by HashRouter)
in HashRouter

अगर मैं हटा देता हूँ

<li><Link to={"/react"}>React</Link></li>

मेरे कोड से तब पृष्ठ ठीक से लोड होता है। मैं घटक पर लिंक बनाने की पुरानी विधि का उपयोग कर रहा हूँ?

किसी भी संकेत की सराहना की जाती है ...

उत्तर:

जवाब के लिए 5 № 1

लिंक अब प्रतिक्रिया-राउटर-डोम पैकेज का हिस्सा है। इसलिए आपको अपना आयात बदलना चाहिए:

import { Link } from "react-router-dom";

उत्तर № 2 के लिए 1

आपको आयात करने की आवश्यकता है Link से react-router-dom, आप उदाहरण की जाँच कर सकते हैं यहाँ। इसके अलावा, कोष्ठक का उपयोग करने की कोई आवश्यकता नहीं है, आप बस कर सकते हैं: <Link to="/react">React</Link>.