Blue - v0.0.17
Add RouteWrapper HOC
In beacon embed, we had a problem where we wanted to fetch some data from the server before navigating to a new . To make this easier, this Pull Request creates a Higher Order Component, RouteWrapper
, which wraps around components and adds fetch
and to
properties. The to
property works like the to
on a React Router <Link>
, but the fetch
property lets you specify a thunk-returning function to fetch data before triggering the route specified in to
.
The <Link>
and <Button>
components have been wrapped with RouteWrapper
, which means we can now do things like:
<Link fetch="fetchArticle" to={`docs/articles/${id}`}>
<Button fetch="fetchArticles" to="docs/articles">
<Button to="synchronous/route/path">
Implement specified enum propTypes
This update provides most components with a specific range of acceptable values.
For example, the states (string
) that we use in Blue are error
, success
, warning
. Components with a state
prop should only accept these values, as other values will fall to render the correct styling.
To be things easier (and more consistent), I've added constants/propTypes.js
that contain an export of common propTypes, such as state or size.