{"id":4282,"url":"https://github.com/mfrachet/rn-ab-hoc","last_synced_at":"2025-04-13T13:31:49.897Z","repository":{"id":66323492,"uuid":"96105013","full_name":"mfrachet/rn-ab-hoc","owner":"mfrachet","description":":two_men_holding_hands: :two_women_holding_hands: Poor intrusive way to make A/B Testing by using an HoC instead of components","archived":false,"fork":false,"pushed_at":"2017-11-02T07:23:19.000Z","size":300,"stargazers_count":25,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T05:01:38.304Z","etag":null,"topics":["ab-testing","react","react-native"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mfrachet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-07-03T11:45:42.000Z","updated_at":"2023-04-25T14:50:14.000Z","dependencies_parsed_at":"2023-05-01T06:15:17.056Z","dependency_job_id":null,"html_url":"https://github.com/mfrachet/rn-ab-hoc","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfrachet%2Frn-ab-hoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfrachet%2Frn-ab-hoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfrachet%2Frn-ab-hoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfrachet%2Frn-ab-hoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mfrachet","download_url":"https://codeload.github.com/mfrachet/rn-ab-hoc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248721136,"owners_count":21151051,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ab-testing","react","react-native"],"created_at":"2024-01-05T20:17:06.794Z","updated_at":"2025-04-13T13:31:44.885Z","avatar_url":"https://github.com/mfrachet.png","language":"JavaScript","funding_links":[],"categories":["Components","Others"],"sub_categories":["UI"],"readme":"[![Build Status](https://travis-ci.org/mfrachet/rn-ab-hoc.svg?branch=master)](https://travis-ci.org/mfrachet/rn-ab-hoc)\n[![Coverage Status](https://coveralls.io/repos/github/mfrachet/rn-ab-hoc/badge.svg?branch=master)](https://coveralls.io/github/mfrachet/rn-ab-hoc?branch=master)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n\nPoor intrusive way to make A/B Testing by using an `HoC` instead of components.\n\n---\n\u003cp align=\"center\"\u003e\n\u003cimg height=\"300\" src=\"https://img4.hostingpics.net/pics/219640VariantFlatList.gif\"/\u003e\n\u003cimg height=\"300\" src=\"https://img4.hostingpics.net/pics/966777VariantListView.gif\"/\u003e\n\u003c/p\u003e\n\n---\n\n\n\n\n# Usage\n\n### Installation\n\n```\n$ npm install --save rn-ab-hoc\n```\n\n### Component\n\n\n```javascript\n/* list.js */\n\nimport abConnect from 'rn-ab-hoc';\nimport FlatList from './flatList.js';\nimport ListView rom './listView.js';\nimport OtherList rom './otherList.js';\n\nexport default abConnect('ListExperiment',\n { variant: 'FlatList', component: FlatList },\n { variant: 'ListView', component: ListView },\n { variant: 'OtherList', component: OtherList }\n);\n```\n\nThe previous code defines :\n\n- An experiment name\n- A list of different variants with their names and associated components\n\n### Using a random variant\n\n\n```javascript\n/* app.js */\n\nimport React from 'react';\nimport List from './list';\n\nexport default function App() {\n    return (\n      \u003cList /\u003e\n    );\n}\n```\n\nThis will load one of the three previous components (variants) defined using a [randomize function](https://github.com/mfrachet/rn-ab-hoc/blob/master/src/reactNativeAbHoc.js#L16)\n\n### Forcing a variant\n\n```javascript\n/* app.js */\n\nimport React from 'react';\nimport List from './list';\n\nexport default function App() {\n    return (\n      \u003cList variant=\"FlatList\" /\u003e\n    );\n}\n```\n\nThis will force a specific variant (maybe sent by your backend) to be used inside the app.\n\n*Note that the forced variant takes over the random one. If you set a variant by forcing it, the previous random one will be erased and replaced by the forced one. Inverse is not true.*\n\n### Which variant am I using ?\n\n```javascript\n/* app.js */\n\nimport React from 'react';\nimport List from './list';\n\nexport default function App() {\n    return (\n      \u003cList\n        variant=\"FlatList\"\n        onVariantSelect={(variant) =\u003e console.log(variant)}\n      /\u003e\n    );\n}\n```\n\nThis will print `FlatList`. It also work with random variants.\n\n\n### Storage\n\nThe default storage system is  [`AsyncStorage`](https://facebook.github.io/react-native/docs/asyncstorage.html) with a key that follows the pattern :\n\n```javascript\nabhoc-variant-${experiment}\n```\n\nIn the previous case, it would have been :\n\n```\nabhoc-variant-ListExperiment\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfrachet%2Frn-ab-hoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmfrachet%2Frn-ab-hoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfrachet%2Frn-ab-hoc/lists"}