1.1.3 • Published 2 years ago

laika-react v1.1.3

Weekly downloads
53
License
MIT
Repository
github
Last release
2 years ago

laika-react

laika-react is an NPM package that connects React applications with the Laika feature flag service (https://github.com/MEDIGO/laika)

Installation and Usage

Install laika-react with yarn or npm

yarn add laika-react

or

npm install laika-react

Then import it into your React app

import React from 'react'
import Laika from 'laika-react'
import NewComponent from './NewComponent'
import OldComponent from './OldComponent'

export default function App() {
  return (
    <div>
        <Laika
            uri='http://example.com'
            feature='NEW_COMPONENT'
            env='dev'
            onTrue={<NewComponent />}
            onFalse={<OldComponent />}
        />
    </div>
  )
}

Props

  • uri - The uri for the call to the laika server
  • feature - The name of the feature on the laika server
  • env - The environment of the React component
  • onTrue - The new feature component to be rendered when laika returns true
  • onFalse - The old component to be rendered when laika returns false

getFeatureStatus

laika-react also exposes getFeatureStatus(feature: string, uri: string, env: string): Promise<boolean>. This allows different conditions to be run based on the feature's status instead of just rendering React components. e.g.

import { getFeatureStatus } from 'laika-react'

getFeatureStatus('NEW_FEATURE', 'http://example.com', 'prod')
  .then(status => {
    if (status) {
      console.log('feature enabled')
    }
  })

Demo

To try out the demo cd demo yarn install yarn start

and the demo will be available at http://localhost:3000/

License

MIT Licensed. Copyright (c) Medigo GmbH 2019.

1.1.3

2 years ago

1.1.1

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

4 years ago

0.1.6-alpha.2

4 years ago

0.1.6-alpha.1

4 years ago

0.1.5

4 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago