Skip to content

Add `SwitchFeature`, rebrand `FeatureToggled` and performance improvements

Compare
Choose a tag to compare
@tdeekens tdeekens released this 09 Dec 20:07
· 2091 commits to main since this release

馃挘 Breaking changes

  • FeatureToggled and render (func) is now only invoked when feature matches
  • children on the other-hand is invoked with isFeatureEnabled in any case
    • This matches behaviour in react-router
  • Anywhere you used variate you should now use variation
    • We used the wrong terms here sorry for the confusion

馃毈 Deprecations

  • FeatureToggled got renamed to ToggleFeature
    • FeatureToggled will be supported for some time but using it will give you a warning

馃専 Features

  • SwitchFeature is new component rendering the first matching ToggleFeature
    • It hope to ease so called multi variate testing by ensuring that only one feature is rendered at a time
<SwitchFeature>
   <ToggleFeature flag="foo" variation="bar" toggledComponent={MyFeature}/>
   <ToggleFeature flag="foo" variation="baz" render={() => <p>Turned on</p>} />
   <ToggleFeature flag="foo" variation="bar">
       { ({ isFeautureEnabled } ) => <p>Turned on?: { isFeatureEnabled }</p> }
   </ToggleFeature>
   <ToggleFeature flag="foo" variation="foo" toggledComponent={MyFeature} untoggledComponent={DisabledFeature}/>
</SwitchFeature>

馃 Fixes

  • ConfigureFlopflip is now more mindful about not triggering wasteful renders
    • All of its unrelated state is extracted away from React to speed up your app
  • ConfigureFlopflip and the underlying FlagSubscription had a hairy infinite configuration loop
    • The needed mix of componentDidMount and componentDidUpdate in pair with configure and reconfigure lead to a repeated brute force configuration of adapters which yielded a stack overlow
    • While fixing the bug we improved our internal state handling from naive boolean flags to more descriptive enums
  • Wrapping of displayNames is now removed for all components
    • This makes snapshotting more consistent between releases
    • It eases testing with enzyme (a wrapper.find('ToggleFeature is enough)

馃挊 Tooling

  • Dependencies have been updated again making sure flopflip is compatible with React@16.2