- Support all properties that normal component can use.
- Support custom tag of
Link
component (default tag isa
). - Support custom children, tag children.
- React Native compatible.
- Fit for more flexible use scences.
-
to
The path linked to.<Link to={ pathname + '/overview' }>Overview</Link>
-
state
The state of next location, can readed byControl.state
<Link to='/overview' state={{ id: 123, name: 'John' }}>Overview</Link>
-
type
The tag to render, default 'a'.<Link type='img' src='http://localhost/favicon.ico' className='button' to={ '/overview' }/>
This will render to:
<img src='http://localhost/favicon.ico' class='button' />
-
children
Support custom children, element children.-
Custom children
<Link type='li' className='button' to={ pathname + '/overview' } > <a style={{ color: 'red' }}>Overview</a> </Link>
This will render to:
<li class='button'> <a style='color:red'>Overview</a> </li>
-
Element children, which can support React Native
import CustomComponent from './CustomButton' <Link type={ CustomComponent } className='button' to={ pathname + '/overview' } > <a style={{ color: 'red' }}>Overview</a> </Link>
This will render to:
<CustomComponent class='button'> <a style='color:red'>Overview</a> </CustomComponent>
-
You can create more flexible use scences by
type
andchildren
.
-
-
activeClassName
TheactiveClassName
will be added to the tag whenactive
.<Link to={ pathname + '/overview' } className='button' activeClassName='active'>Overview</Link>
-
activeStyle
TheactiveStyle
will be added to the tag whenactive
.<Link to={ pathname + '/overview' } className='button' activeClassName='active' activeStyle={{ color: 'red' }}>Overview</Link>
-
isActive
isActive
is the active flag of theLink
component, its's default value is computed by comparing thepathname
with the value ofto
.
You can define your own compute rule with this propertyimport { Control, Link } from 'react-keeper' <Link to={ pathname + '/overview' } isActive={ Control.path === pathname || Control.path === (pathname + '/overview') }>Overview</Link>
import { Control, Link } from 'react-keeper' <Link to={ pathname + '/overview' } isActive={ ()=>{ return Control.path.indexOf(pathname) === 0 } }>Overview</Link>