You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose a "withMetrics" higher order component that accepts a react-redux style 'mapMetricsToProps' function to map metrics API functions to a components props.
The above example demonstrates the usage of such a HOC to compose tracked checkout buttons using a common curried function that wraps the track() call from react-metrics.
A more simplistic example would be exposing the react-metrics API functions directly to the wrapped component
exportdefaultwithMetrics(metrics=>{trackSomething: metrics.track})(MyTrackedComponent);// Named tracking methodsexportdefaultwithMetrics()(MyOtherTrackedComponent);// Default passing all react-metrics api functions as props
Interested to know if this feature sounds reasonable to implement directly into this repository and if you would accept PRs for such a feature.
The text was updated successfully, but these errors were encountered:
I can start working on a PR for the above feature, though I can potentially see some wider refactoring to reduce the ambiguity of a exposeMetrics and withMetrics function.
The catalyst of this request comes from me stumbling across this from Dan Abramov: https://twitter.com/dan_abramov/status/749715530454622208
Backing this up, the react docs recommend not to use the context directly https://facebook.github.io/react/docs/context.html#why-not-to-use-context
I propose a "withMetrics" higher order component that accepts a react-redux style 'mapMetricsToProps' function to map metrics API functions to a components props.
The above example demonstrates the usage of such a HOC to compose tracked checkout buttons using a common curried function that wraps the
track()
call from react-metrics.A more simplistic example would be exposing the react-metrics API functions directly to the wrapped component
Interested to know if this feature sounds reasonable to implement directly into this repository and if you would accept PRs for such a feature.
The text was updated successfully, but these errors were encountered: