1.1.0 • Published 5 years ago

@mathdoy/toggle-querystring v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Installation

$ npm install --save @mathdoy/toggle @mathdoy/toggle-querystring
import { createToggle } from "@mathdoy/toggle";
import { createToggleQuerystring } from "@mathdoy/toggle-querystring";

// ...

const toggleQuerystring = createToggleQuerystring({
  // Query string parameter
  param: "features",
  // Default features
  features: {
    logo: true,
  },
});

const toggle = createToggle({
  features: toggleQuerystring(window.location.search),
});

// toggleQuerystring("?features[foo]=1&features[bar]&features[qaz]=false")
// {
//     logo: true,
//     foo: true,
//     bar: true,
//     qaz: false
// }

// toggleQuerystring("?features[logo]=false")
// { logo: false } // default has been overriden

See a full example in toggle/blob/master/examples/react/src/index.js

For more information on toggle

For more information on toggle see toggle

Using it with react

$ npm install --save @mathdoy/toggle @mathdoy/toggle-querystring @mathdoy/toggle-react

See more information for toggle-react

License

Toggle is licensed under the MIT License.