对于react-router–在navitem中的React-Bootstrap链接项感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解reactrouterlink,并且为您提供关于Boot
对于react-router – 在navitem中的React-Bootstrap链接项感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解react router link,并且为您提供关于Bootstrap 组件 reactstrap 和 react.Component 之间的连接、Carousel在react-bootstrap中的react-image-mapper无法正常工作、javascript – 如何使用Jest 0.8.x中的react-router 2.0测试使用上下文的React组件、React Bootstrap — React 构建的 Bootstrap3 组件的宝贵知识。
本文目录一览:- react-router – 在navitem中的React-Bootstrap链接项(react router link)
- Bootstrap 组件 reactstrap 和 react.Component 之间的连接
- Carousel在react-bootstrap中的react-image-mapper无法正常工作
- javascript – 如何使用Jest 0.8.x中的react-router 2.0测试使用上下文的React组件
- React Bootstrap — React 构建的 Bootstrap3 组件
react-router – 在navitem中的React-Bootstrap链接项(react router link)
import { Route,RouteHandler,Link } from 'react-router'; import AuthService from '../services/AuthService' import { Button,Nav,Navbar,NavDropdown,MenuItem,NavItem } from 'react-bootstrap'; <Nav pullRight> <NavItem eventKey={1}> <Link to="home">Home</Link> </NavItem> <NavItem eventKey={2}> <Link to="book">Book Inv</Link> </NavItem> <NavDropdown eventKey={3} title="Authorization" id="basic-nav-dropdown"> <MenuItem eventKey="3.1"> <a href="" onClick={this.logout}>logout</a> </MenuItem> </NavDropdown> </Nav>
这是渲染时的外观。
我知道< Link>< / Link>是造成这个,但我不知道为什么?我想这样做是在线的。
警告:validateDOMnesting(…):< a>不能显示为< a>的后裔。参见标题> NavItem> SafeAnchor> a> …>链接>一个。
这是因为当NavItem渲染时,锚(NavItem的直接子代)已经存在。
由于上述的警告,反应将被迫把这两个锚点当作兄弟姐妹,这样造成了风格问题。
Bootstrap 组件 reactstrap 和 react.Component 之间的连接
基本上,是的。您可以扩展 React.Component 来创建您自己的基于类的自定义 React 组件。您正在导入的其他库来自库作者已创建组件的库。请注意,您还可以在不扩展 React.Component 的情况下创建自定义的基于函数的 React 组件。我建议通读React.Component documentation。
关于它与 CustomModal 的关系的问题,您将使用 Modal 作为 CustomModal 中的一个组件。例如:
import React,{ Component } from "react";
import {
Button,Modal,} from "reactstrap";
export default class CustomModal extends Component {
...
render() {
return <Modal />;
}
}
请注意,此示例只是让您了解如何在您自己的自定义组件中使用导入的组件。不一定是如何使用 reactstrap.Modal
本身。
Carousel在react-bootstrap中的react-image-mapper无法正常工作
如何解决Carousel在react-bootstrap中的react-image-mapper无法正常工作?
我正在尝试创建一个图像轮播,用户可以单击它,每个图像上都有由react-image-mapper库生成的映射。
当我发送一个实际的图像标签时,我可以使轮播工作,但是当尝试将图像标签与通过react-image-mapper库生成的画布和地图一起发送时,整个过程就坏了。映射消失了,仅显示了3张图像中的第一张。在代码中,其他图像在那里,但是实际上并没有显示在浏览器中。
每个映射的图像都包装在div中,因此结构如下:
<div>
<img>
<canvas>
<map>
</div>
我的渲染代码如下:
<Carousel activeIndex={index} onSelect={handleSelect}>
{renderItems}
</Carousel>
{renderItems}是通过遍历一系列图像路径并将它们链接到ImageMapper对象而生成的。
const renderItems = boardPics.map((img,index) => {
boardImg.src = img;
boardMappings.forEach((key) => {
boardMap.push(BOARDMAPPINGS[key]);
});
return (
<BoardMap
boardUrl={img}
width={boardImg.width / 2}
fullWidth={boardImg.width}
map={boardMap[index]}
/>
);
});
BoardMap将所有这些通过道具发送到我的ImageMapper文件,该文件返回以下内容:
return (
<ImageMapper src={boardUrl} map={map} width={width} imgWidth={fullWidth} />
);
不确定我是否缺少某些东西,这是行不通的,还是我需要创建一个自定义函数来生成轮播。
我已经坚持了3天,因此非常感谢您的帮助。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
javascript – 如何使用Jest 0.8.x中的react-router 2.0测试使用上下文的React组件
我认为这将在未来有所改善,但我与react-router 2.0打同一面(我不是说这是react-router的一个问题,但因为它使用了上下文,它会影响我的测试).所以,我有一个组件使用上下文将新状态推入url this.context.router.push(…)这是现在的方法
https://github.com/reactjs/react-router/blob/master/upgrade-guides/v2.0.0.md#programmatic-navigation
我告诉jest.dontMock(‘react-router’)但我的测试将失败:
TypeError:无法读取未定义的属性“push”
发生这种情况是因为TestUtils.renderIntodocument返回的实例将具有:
context:Object {router:undefined}
现在,这里真正的问题是什么?是Jest吗?我很确定我不是唯一一个遇到这种情况的人,自stubRouterContext以来它不再是在反应路由器的official docs中,是否有任何广泛接受的解决方案?
我如何使测试工作?这基本上具有正确的上下文,并且能够从TestUtils.renderIntodocument返回的组件实例访问所有内容.
我正在使用react 0.14.7,jest-cli 0.8.2和react-router 2.0.
解决方法
// dontmock.config.js contains jest.dontMock('components/Breadcrumbs') // to avoid issue with hoisting of import operators,which causes // jest.dontMock() to be ignored import dontmock from 'dontmock.config.js'; import React from "react"; import { Router,createMemoryHistory } from "react-router"; import TestUtils from "react-addons-test-utils"; import Breadcrumbs from "components/Breadcrumbs"; // Create history object to operate with in non-browser environment const history = createMemoryHistory("/products/product/12"); // Setup routes configuration. // JSX would also work,but this way it's more convenient to specify custom // route properties (excludes,localized labels,etc..). const routes = [{ path: "/",component: React.createClass({ render() { return <div>{this.props.children}</div>; } }),childRoutes: [{ path: "products",component: React.createClass({ render() { return <div>{this.props.children}</div>; } }),childRoutes: [{ path: "product/:id",component: React.createClass({ // Render your component with contextual route props or anything else you need // If you need to test different combinations of properties,then setup a separate route configuration. render() { return <Breadcrumbs routes={this.props.routes} />; } }),childRoutes: [] }] }] }]; describe("Breadcrumbs component test suite:",() => { beforeEach(function() { // Render the entire route configuration with Breadcrumbs available on a specified route this.component = TestUtils.renderIntodocument(<Router routes={routes} history={history} />); this.componentNode = ReactDOM.findDOMNode(this.component); this.breadcrumbNode = ReactDOM.findDOMNode(this.component).querySelector(".breadcrumbs"); }); it("should be defined",function() { expect(this.breadcrumbNode).tobedefined(); }); /** * Now test whatever you need to */
React Bootstrap — React 构建的 Bootstrap3 组件
React Bootstrap 是由 React 构建的 Bootstrap 3 组件,也是最受欢迎的前端框架之一。
我们今天的关于react-router – 在navitem中的React-Bootstrap链接项和react router link的分享就到这里,谢谢您的阅读,如果想了解更多关于Bootstrap 组件 reactstrap 和 react.Component 之间的连接、Carousel在react-bootstrap中的react-image-mapper无法正常工作、javascript – 如何使用Jest 0.8.x中的react-router 2.0测试使用上下文的React组件、React Bootstrap — React 构建的 Bootstrap3 组件的相关信息,可以在本站进行搜索。
本文标签: