Added:
- Pass object of key value query parameters to
Switch
props (params
),onChange
callback, andrenderSwitch
function. 797be1b
Fixed:
- Fix a bug that prevented
Switcher
event listeners from being removed when nested inSwitcherProvider
. e4ef9c6
Added:
- Added
SwitcherProvider
component. This can be wrapped at the top level such that browser events (load
,pushState
,hashChange
) are registered only once for the entire tree rather than for eachSwitcher
within the app.
Changed:
- The
dist
directory is no longer checked into git. These files are only included in the npm package or using unpkg.
Fixed:
- Make
prop-types
a peer dependency to help switcheroo users get rid of warnings. b286b6c
Fixed:
- Prevent prettier from running on built files in
dist
. This one will actually updatedist
correctly f8bb603
Fixed:
- Update build in
dist
Fixed:
- Correctly configure rollup for production to strip out development code. 506fc6c
Fixed:
- Move away from deprecated
React.PropTypes
and useprop-types
package. 4ad51a5
Added:
- Added
activePath
as an argument toonChange
andrenderSwitch
callbacks. It also gets set as a prop on the component being rendered.activePath
is the RegExp string path (as defined on theSwitch
's prop) that was matched. It essentially provides information about why a component was rendered (by which matching path), which is mostly useful when an array of paths are passed in as props.
Fixed:
- No longer assumes props.children is an array. 3ec6428
Added:
- Moved build to rollup and added new build targets (amd, ES2015, commonjs, umd). The build still defaults to the minified umd build so there will be no noticeable differences except that the build is slightly smaller. e807a30
Changed:
Switcher
no longer passes all its props to wrapper components. It now only passes through additional props (ones that are notSwitcher
props).
Added:
- Introduce
renderSwitch
prop, that can accepts a render function to provide more fine-grained control that thewrapper
prop cannot provide. 2a7b65d
Added:
- Support React
^15.0.0
as a peerDependency. ab95e2e
Fixed:
- Fix bug where dynamic segments were not set on initial mount or subsequent mounts. 19a58c2
Fixed:
- Fix bug where multiple paths ending in the same pattern would cause wrong nodes to render. 0398f56
Added:
- Allow paths to contain dynamic segments. These dynamic segments are passed to the component as props. 2aaa657 95be79d
- Add
mapDynamicSegments
prop to enable transforming dynamic segment data before it is passed as props. 2aaa657 95be79d
Fixed:
- Allow
Switcher
to render a null child. 2b51da2
Added:
- Added
preventUpdate
optional function prop toSwitcher
. When the function returns true, it prevents rendering changes. 562fa59
Fixed:
Switch
now correctly receives new props passed in. Previously rendering would be stale in certain situations. dc94afc
Fixed:
- Loosen
wrapper
PropType constraints onSwitcher
component. Allow nodes, React elements, and strings representing DOM nodes as well. 612e6c0
Fixed:
- Fix accidentally commented out build config so the build is minified and optimized for production again. cd445b0
Changed:
- Made
Switcher
the default export instead of a named export from the library. 9d97f19 Wherever usingSwitcher
change as follows:
// old
import {Switcher} from 'switcheroo';
// new
import Switcher from 'switcheroo';
Fixed:
- Fixed bug that prevented the
Switch
path,/.*
, from matching/
. 0b2448e
Changed:
- Removed optional
defaultHandler
anddefaultHandlerProps
properties. These are no longer necessary since regular expressions are now used for thepath
prop, meaning that the default component can be the lastSwitch
with apath
regular expression that matches everything. 38e843e
Since this is a breaking change see how to migrate existing code that uses these props below:
<Switcher defaultHandler={MyComponent} defaultHandlerProps={myComponentProps}>
<Component1 path="/path1" />
<Component2 path="/path2" />
</Switcher>
becomes
<Switcher>
<Component1 path="/path1" />
<Component2 path="/path2" />
<MyComponent path="/.*" {...myComponentProps} />
</Switcher>
Changed:
- Removed external
window
from webpack build configuration. This requires less configuration from end users and the external was not providing any meaningful value. fe53f76
Changed:
- Upgraded to React 0.14.0. 81b5603
Fixed:
- Google Closure Compiler seems to break some things and gives this error when Switcheroo is used with webpack:
Super expression must either be null or a function, not undefined
. 52a3b4d
Changed:
- Reduced build size with Google Closure Compiler. b72049b
Added:
- Allow
Switch
path
property to take a string representing a regular expression or an array of them. a55a73e
Breaking Changes:
- Removed
route-recognizer
dependency.path
prop now expects regular expression strings. eg:<Component path="/myPath/valueA|valueB/.+" />. This means that paths with
route-recognizerspecific features like dynamic segments (
/path/:dynamic/more) or star segments (
/path/*theRest`) will no longer work and should be updated. Most other paths should work without changes. 76df023
Fixed:
- Remove
setState
being called before component was mounted (removes warnings) 20c60de
Fixed:
- When a
Switch
'sprops
change ensure that the component is rendered with the correct data. This was previously using staleprops
from initialization as theSwitch
es are set to the handlers forroute-recognizer
route matches, so these references need to be updated on the React lifecycle,componentWillReceiveProps
. 2f8316a
Added:
route-recognizer
dependency added to handle matching paths. This allows for dynamic segments and star segments which are covered in the docs. 3d5da48
Added:
Switcher
accepts optionalwrapper
prop. This specifies a component to wrap the rendered component with. 10dd2deSwitcher
now acceptsload
andhashChange
. These both default to true and control the event listeners thatSwitcher
checks for path changes on. These work in conjunction with the existingpushState
prop. 1003c14Switcher
acceptslocation
prop, that defaults tohash
. This is used for path comparison (window.location[this.props.location]
). a91e604Switcher
acceptsbasePath
prop that defaults to ''. This is prepended to all component path props inSwitcher
. 862f5fd
Changed:
Switch
path now ignores query params. This means aSwitch
with a path/abc
renders for/abc
and/abc?a=1&b=2
. 575bfb0
Changed:
onChange
method is called right beforeSwitcher
renders new component. 0bbf93b
Added:
Switcher
accepts optionalonChange
prop. This is a function that gets called when the route changes. 2f0c5d0Switch
accepts optionalonShow
/onHide
props. These are functions that get called when theSwitch
is rendered/removed from the view. 14aafeaSwitcher
accepts optionaldefaultHandler
/defaultHandlerProps
props. This is the default component that is rendered when there is not a matchingSwitch
path. If one is not specified, nothing is rendered (a render function returning false). 97f956Switch
accepts optionalhandlerProps
prop. If defined this object is passed as props to the handler. b9b7efc
Fixed:
Switcher
component can now have less than twoSwitch
s in it without erroring. afe4e90
- First working release!