Skip to content

Commit

Permalink
Pass Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiodxa committed Mar 21, 2024
1 parent fc49ee8 commit 4c978fe
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 52 deletions.
24 changes: 12 additions & 12 deletions example/public/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Flagged Example website made with CRA" />
<title>Flagged Example</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Flagged Example website made with CRA" />
<title>Flagged Example</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
80 changes: 40 additions & 40 deletions example/src/index.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { FlagsProvider, withFeature, Feature, useFeature } from 'flagged';
import React from "react";
import ReactDOM from "react-dom";
import { FlagsProvider, withFeature, Feature, useFeature } from "flagged";

function VersionComponent({ version }) {
return <h1>You are currently in {version}.</h1>;
return <h1>You are currently in {version}.</h1>;
}

// Custom Hook
function V1Component() {
const hasV1 = useFeature('v1');
if (!hasV1) return null;
return <VersionComponent version="v1" />;
const hasV1 = useFeature("v1");
if (!hasV1) return null;
return <VersionComponent version="v1" />;
}

// High Order Component
const V2Component = withFeature('v2')(function V2Component() {
return <VersionComponent version="v2" />;
const V2Component = withFeature("v2")(function V2Component() {
return <VersionComponent version="v2" />;
});

function V3Component() {
return <VersionComponent version="v3" />;
return <VersionComponent version="v3" />;
}

function V4Component() {
return <VersionComponent version="v4" />;
return <VersionComponent version="v4" />;
}

function App() {
const [version, setVersion] = React.useState(1);
const [version, setVersion] = React.useState(1);

return (
<FlagsProvider
features={{
v1: version === 1,
v2: version === 2,
v3: version === 3,
v4: version === 4,
}}
>
<label>
Version{' '}
<input
type="number"
value={version}
onChange={e => setVersion(Number(e.target.value))}
/>
</label>
return (
<FlagsProvider
features={{
v1: version === 1,
v2: version === 2,
v3: version === 3,
v4: version === 4,
}}
>
<label>
Version{" "}
<input
type="number"
value={version}
onChange={(e) => setVersion(Number(e.target.value))}
/>
</label>

<V1Component />
<V1Component />

<V2Component />
<V2Component />

{/* Render Prop */}
<Feature name="v3" render={<V3Component />} />
{/* Render Prop */}
<Feature name="v3" render={<V3Component />} />

{/* Function as Children */}
<Feature name="v4">
{hasV4 => (hasV4 ? <V4Component /> : <h3>You are not in v4.</h3>)}
</Feature>
</FlagsProvider>
);
{/* Function as Children */}
<Feature name="v4">
{(hasV4) => (hasV4 ? <V4Component /> : <h3>You are not in v4.</h3>)}
</Feature>
</FlagsProvider>
);
}

ReactDOM.render(<App />, document.getElementById('root'));
ReactDOM.render(<App />, document.getElementById("root"));

0 comments on commit 4c978fe

Please sign in to comment.