From 4a3b3e219b7898eba2aa00c86bca02e923abccc0 Mon Sep 17 00:00:00 2001
From: Pavel <14926950+prichodko@users.noreply.github.com>
Date: Fri, 1 Jul 2022 17:21:08 +0200
Subject: [PATCH] [examples] Set public key from environment variable (#291)
* use env variables in example
* add .env.local to gitignore
---
.gitignore | 1 +
examples/community/.env.example | 1 +
examples/community/src/app.tsx | 12 ++++++++++--
3 files changed, 12 insertions(+), 2 deletions(-)
create mode 100644 examples/community/.env.example
diff --git a/.gitignore b/.gitignore
index 7afb4de..272915c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -60,6 +60,7 @@ node_modules/
# dotenv environment variables file
.env
.env.test
+.env.local
# parcel-bundler cache (https://parceljs.org/)
.parcel-cache
diff --git a/examples/community/.env.example b/examples/community/.env.example
new file mode 100644
index 0000000..6709172
--- /dev/null
+++ b/examples/community/.env.example
@@ -0,0 +1 @@
+PUBLIC_KEY=""
diff --git a/examples/community/src/app.tsx b/examples/community/src/app.tsx
index dd7f6f2..75beea9 100644
--- a/examples/community/src/app.tsx
+++ b/examples/community/src/app.tsx
@@ -2,6 +2,14 @@ import React from 'react'
import { Community } from '@status-im/react'
-export const App = () => {
- return
+const publicKey = process.env.PUBLIC_KEY
+
+if (!publicKey) {
+ throw new Error(
+ 'Add PUBLIC_KEY to your environment variables (see .env.example)'
+ )
+}
+
+export const App = () => {
+ return
}