Skip to content

Commit 82ff784

Browse files
committed
3.12.0 bump - Use json getValue fallback when flag is null
1 parent cd3a12f commit 82ff784

File tree

24 files changed

+15742
-28
lines changed

24 files changed

+15742
-28
lines changed

examples/nextjs/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/nextjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"flagsmith-es": "3.10.4",
12+
"flagsmith-es": "3.12.0",
1313
"lodash-es": "^4.17.21",
1414
"next": "12.1.0",
1515
"next-transpile-modules": "^9.0.0",

examples/nextjs/pages/_app.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ const environmentID = "QjgYur4LQTwe5HpvbvhpzK"
99
function MyApp({ Component, pageProps, flagsmithState }: AppProps & {flagsmithState: IState}) {
1010
return (
1111
<FlagsmithProvider flagsmith={flagsmith}
12+
options={{
13+
environmentID,
14+
enableLogs: true,
15+
cacheFlags: true,
16+
cacheOptions: {skipAPI:true,ttl:5000}
17+
}}
1218
serverState={flagsmithState as IState}
1319
>
1420
<Component {...pageProps} />

examples/nextjs/pages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ const Home: NextPage = () => {
1313
json: true,
1414
fallback: {foo:null,bar:null}
1515
});
16+
console.log(json)
1617

1718
const font_size = flagsmith.getValue("font_size", {fallback:null})
1819

1920
return (
2021
<div className="App">
2122
font_size: {flags.font_size?.value}
2223
example_trait: {flags.example_trait}
23-
example_json_trait: {`foo ${json.foo}, bar ${json.bar}`}
2424
{
2525
flagsmith.identity? (
2626
<button onClick={()=>flagsmith.logout()}>

flagsmith-core.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,10 @@ const Flagsmith = class {
639639

640640
if (options?.json) {
641641
try {
642+
if (res === null) {
643+
this.log("Tried to parse null flag as JSON: " + key)
644+
return options.fallback;
645+
}
642646
return JSON.parse(res as string)
643647
} catch (e) {
644648
return options.fallback

lib/flagsmith-es/index.js

Lines changed: 3123 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/flagsmith-es/isomorphic.js

Lines changed: 3120 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/flagsmith-es/next-middleware.js

Lines changed: 753 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/flagsmith-es/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flagsmith-es",
3-
"version": "3.11.0",
3+
"version": "3.12.0",
44
"description": "Feature flagging to support continuous development. This is an esm equivalent of the standard flagsmith npm module.",
55
"main": "./index.js",
66
"type": "module",

lib/flagsmith-es/react.js

Lines changed: 195 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)