Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Submit feedback
    • Contribute to GitLab
  • Sign in
P
purescript-gargantext
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 142
    • Issues 142
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 4
    • Merge Requests 4
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • gargantext
  • purescript-gargantext
  • Merge Requests
  • !490

Merged
Opened Dec 09, 2024 by Yoelis Acourt@yacourt
  • Report abuse
Report abuse

Feature flag hook

useFeatureFlag is a custom React hook that determines whether a feature flag is enabled based on the presence and value of specific cookies. It checks the cookies provided as keys and returns true if any of them are set to 'true'. Otherwise, it returns false.

This hook is useful for conditional rendering of features based on user-specific feature toggles managed via cookies. Usage :

parentCpt :: R.Component ()
parentCpt = here.component "container" cpt
  where
  cpt _ _ = do
    shouldBeVisible <- useFeatureFlag ["keyOne", "keyTwo", "keyThree"]
    pure $ 
      H.div {} [if shouldBeVisible then H.text "I should be visible" else H.text "Im not visible"]

Use feature component to wrap your component behind a feature flag. It might be cleaner to use it instead of directly using the useFeatureFlag hook Usage:

  feature { keys: [ "keyOne" ], render: \shouldRender -> if shouldRender then H.text "hello" else H.text "you cant see me" }
Edited Dec 09, 2024 by Yoelis Acourt

Check out, review, and merge locally

Step 1. Fetch and check out the branch for this merge request

git fetch origin
git checkout -b feature-flag-hook origin/feature-flag-hook

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git fetch origin
git checkout origin/dev
git merge --no-ff feature-flag-hook

Step 4. Push the result of the merge to GitLab

git push origin dev

Note that pushing to GitLab requires write access to this repository.

Tip: You can also checkout merge requests locally by following these guidelines.

  • Discussion 2
  • Commits 3
  • Pipelines 5
  • Changes 5
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
0
Labels
None
Assign labels
  • View project labels
Reference: gargantext/purescript-gargantext!490

Revert this merge request

This will create a new commit in order to revert the existing changes.

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.

Cherry-pick this merge request

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.