togl-react-provider
v1.0.46
Published
A React provider for handling TOGL updates to the application.
Downloads
20
Maintainers
Readme
Togl React Provider
Togl is a feature management platform that allows feature flags to help teams build better software, faster.
This version of the Togl is compatible with versions 16.3.0 and later of React because it uses React's Context API.
Togl Provider
import { ToglProvider } from 'togl-react-provider';
import Component from 'my-project';
function App() {
return (
<ToglProvider clientId="[clientid]">
<Component />
</ToglProvider>
);
}
Togl Hooks
import { useToglClient, useToglFlags } from 'togl-react-provider';
const { initialized } = useToglClient();
const { myFlag } = useToglFlags<ToglFlags>();
function App() {
if (!initialized) {
return <div>Loading...</div>;
}
return (
<div>
{myFlag && (
<h1>myFlag is active</h1>
)}
</div>
);
}