Closed tbrannam closed 2 years ago
Hey @tbrannam, thank you for your message!
So, the first task is to make react-ab-test
compatible with the upcoming React 17.0, by either:
UNSAFE_
(See https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles)getDerivedStateFromProps
useEffect
Supporting hooks requires more discussion, for example I don't know if they would fit better in a separate / complementary library based on the core lib, or perhaps in a different entry point (eg. import { useExperiment } from '@marvelapp/react-ab-test/hooks'
) . 🤔
Trying to think through how hooks might work - have a simple concept here:
https://codesandbox.io/s/react-ab-test-hooks-1qd20 https://github.com/tbrannam/react-ab-test-hooks
This is amazing, the API is so much cleaner!
I'm thinking that we could also provide a helper similar to react-native
's Platform.select
, eg:
emitter.defineVariants('experiment-name', ['var1', 'var2']);
function Experiment() {
const { selectVariant, emitWin } = useExperiment('experiment-name');
const variantName = selectVariant({
var1: 'Variant 1',
var2: 'Variant 2',
});
return (
<>
<div>{variantName}</div>
<button onClick={emitWin}>Emit win</button>
</>
);
}
That looks cool - I updated my POC
I'm looking at refactoring CoreExperiment to be a functional component that is implemented using the hook instead of having two parallel implementations - and it's mostly coming together pretty well. As part of the implementation - I may change the props to CoreExperiment to to be more like Experiment - as CoreExperiments new function is mostly to act as FC adapter to the Hook.
Any concerns?
@tbrannam nice one! Feel free to submit a PR, or post a link your branch 🙂
Did you find a solution for replacing CoreExperiment.componentWillMount
with hooks?
So I'm pretty far along now - I've integrated my POC into a fork. I've got some tests to write for the hook - and some documentation updates as well. I found another way to resolve the testing requirements for SSR rendering.
The big callouts in my fork is CoreExperiment.jsx and hooks.jsx
https://github.com/tbrannam/react-ab-test/tree/hooks-refactor
It's been awhile - any chance we can get the hooks released outside of a beta tag?
Indeed it would be great hooks released
Following up here. Is this a dead project?
another bump. @moretti is this releasable outside of beta? I'll use beta tag for now.
Closing, This seems to be in master branch.
Closing, This seems to be in master branch.
@tbrannam this is in master for a long time already. the problem is the npm package was last published 2 years ago with version 2.3.0. if you want hooks, you need to use 3.0.0-beta.0
version. can anybody publish this as a stable package version?
Oh that is disappointing. I don't have an inside track with Marvel.
@moretti Is there any chance that the 3.0 could be released as a stable version?
@tbrannam @rtrembecky I'm sorry, my Github notifications were disabled for this repo.
Unfortunately we are not actively using this module anymore, which is the main reason why it was not maintained for the past year.
I just published a new version 3.0.0
, which adds support for hooks (outside of the beta tag) and is compatible with React 17.
Have folks investigated updating to prepare for React Lifecycle event deprecation, and supporting React Hooks?
Thanks for maintaining this fork.