
Security News
pnpm 10.12 Introduces Global Virtual Store and Expanded Version Catalogs
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.
react-mixpanel-browser
Advanced tools
Wrapper of mixpanel-browser for use in React apps.
Provides a MixpanelLib
instance via the context API.
Install the package using NPM or Yarn:
npm install --save react-mixpanel-browser
# or
# yarn add react-mixpanel-browser
Add your Mixpanel token to ./.env
:
REACT_APP_MIXPANEL_TOKEN=<token>
MixpanelProvider
Componentimport React from 'react';
import { MixpanelProvider } from 'react-mixpanel-browser';
const App = (props) => (
<MixpanelProvider>
...
</MixpanelProvider>
);
export default App;
useMixpanel
Hookimport React from 'react';
import { useMixpanel } from 'react-mixpanel-browser';
const Dashboard = (props) => {
const mixpanel = useMixpanel();
if (mixpanel.config.token) { // Check that a token was provided (useful if you have environments without Mixpanel)
mixpanel.track('My Event', {
my_custom_prop: 'foo',
});
}
return (
<>
...
</>
);
};
export default Dashboard;
withMixpanel
High-Order Componentimport React, { Component } from 'react';
import { withMixpanel } from 'react-mixpanel-browser';
class Dashboard extends Component {
render() {
const { mixpanel } = this.props;
if (mixpanel.config.token) { // Check that a token was provided (useful if you have environments without Mixpanel)
mixpanel.track('My Event', {
my_custom_prop: 'foo',
});
}
return (
<>
...
</>
);
}
}
export default withMixpanel(Dashboard);
FAQs
React hook for [mixpanel-browser](https://www.npmjs.com/package/mixpanel-browser).
The npm package react-mixpanel-browser receives a total of 2,486 weekly downloads. As such, react-mixpanel-browser popularity was classified as popular.
We found that react-mixpanel-browser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.
Security News
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.