Skip to content
This repository has been archived by the owner on Mar 20, 2019. It is now read-only.

React-Feature-Toggles #106

Merged
merged 15 commits into from
Jun 21, 2018
Merged

React-Feature-Toggles #106

merged 15 commits into from
Jun 21, 2018

Conversation

jwicks31
Copy link
Contributor

@jwicks31 jwicks31 commented Jun 14, 2018

Resolves #105

Description of Changes

Installing react-feature-toggles required updates to a few dependencies.

  • Updates react & react-dom to v16.4.1
  • Updates @types/react to v16.3.17
  • Updates react-hot-loader to v3.1.3
    -This is not the most up to date version, but v1 would not work with React 16. The current version does not support webpack.
  • Installs react-feature-toggles package
  • Adds FeatureToggle provider component from react-feature-toggles
  • Adds AppContainer provider component from react-hot-loader
  • Adds react-feature-toggles typing declaration .d.ts file.

TO TEST REACT-FEATURE-TOGGLES
Open Netlify Link
screen shot 2018-06-20 at 4 44 56 pm

Add '?ft=foo' to the end of the url.
screen shot 2018-06-20 at 4 44 48 pm

PR Review Checklist

  • Have you tested the changes?
  • Is QE review required? If so, has this been reviewed by QE? (For all new features, review by QE is required. Minor changes which already have passing functional tests may not need a new QE review -- when in doubt, loop in a QE reviewer).
  • Are there code changes that require new unit tests? If so, are those tests included? (A separate PR for tests is not appropriate).
  • Are documentation updates required? If so, does this PR include it? (Separate documentation PR is generally not appropriate).
  • Are the added/edited files named appropriately and located correctly in the project directory structure?


function mergeFeatures(
currentFeatures: ReadonlyArray<string>,
restOfFeatures: ReadonlyArray<string>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restOfFeatures should be:
...restOfFeatures: ReadonlyArray<string>
I am not sure how to do the rest operator.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried ...restOfFeatures: string[]? I think ReadonlyArray is unsupported in TS for rest params

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok cool! That seems to have worked! I noticed that the ReadonlyArray wasn't an option, just wasn't able to figure it out/find the answer after that. Thank you!

Copy link
Contributor Author

@jwicks31 jwicks31 Jun 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it worked on my local machine, but out lint rule changes it to ReadonlyArray<string> and that doesn't work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's possible to avoid this rule in this line if you need

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated to ...restOfFeatures: string[] with the rule, but it is giving this error: Argument of type 'string[]' is not assignable to parameter of type 'string'. Trying to work that out before I merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the correct solution was ...restOfFeatures: Array<ReadonlyArray<string>>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @lautarodragan do you agree?

function getReqQueryFeatures(req?: Req): ReadonlyArray<string>
export { getReqQueryFeatures }

function getBrowserQueryFeatures(search?: string): ReadonlyArray<string>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was not working for some reason. I am having trouble with it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What problem are you having with this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm honestly not really sure what is going on. I thought that I had the types correct and everything, but whenever I'm trying to test to see if it actually works it says that it isn't a function. TypeError: react_feature_toggles_1.getBrowserQueryFeatures is not a function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a problem with react-feature-toggles, I fixed it over there.

@wzalazar
Copy link
Contributor

wooow React 16.4.1, I like so much this PR @jwicks31

@@ -16,7 +16,7 @@ storiesOf('Components/Text', module).addWithJSX(
### Usage
~~~js
<Hash
readonly children?: JSX.Element
readonly children?: any
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add information about this change?

Copy link
Contributor Author

@jwicks31 jwicks31 Jun 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not building after I had updated React. At first some things I read where saying that the recommendation was to use children?: any, but I read a little more over the weekend and I believe React.ReactNode is the correct type for most of them. There are some that could possibly just be strings? But I wasn't sure how to handle them Ex. Hash and HeaderTitle.

@geoffturk
Copy link
Contributor

Nice!

image

🎆

@jwicks31 jwicks31 merged commit 5900f08 into master Jun 21, 2018
@jwicks31 jwicks31 deleted the toggle branch June 21, 2018 16:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants