Toggle React library for toggle
$ npm install --save @mathdoy/toggle @mathdoy/toggle-react @mathdoy/toggle-next-wrapper
# If you use a custom server you can install @mathdoy/toggle-middleware to allow overriten config from headers
$ npm install --save @mathdoy/toggle-middleware
import React from "react";
import App, { Container } from "next/app";
import { createToggle } from "@mathdoy/toggle";
import { ToggleProvider } from "@mathdoy/toggle-react";
import withToggleNext from "@mathdoy/toggle-next-wrapper";
import initialToggle from "../toggle";
class MyApp extends App {
static async getInitialProps({ Component, ctx }) {
return {
pageProps: Component.getInitialProps
? await Component.getInitialProps(ctx)
: {},
};
}
render() {
const { Component, pageProps, toggle } = this.props;
return (
<Container>
<ToggleProvider toggle={createToggle(toggle)}>
<Component {...pageProps} />
</ToggleProvider>
</Container>
);
}
}
export default withToggleNext(initialToggle)(MyApp);
For more information on toggle see toggle
Toggle is licensed under the MIT License.