[examples] Set public key from environment variable (#291)

* use env variables in example

* add .env.local to gitignore
This commit is contained in:
Pavel 2022-07-01 17:21:08 +02:00 committed by GitHub
parent 8c83ddb6da
commit 4a3b3e219b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

1
.gitignore vendored
View File

@ -60,6 +60,7 @@ node_modules/
# dotenv environment variables file # dotenv environment variables file
.env .env
.env.test .env.test
.env.local
# parcel-bundler cache (https://parceljs.org/) # parcel-bundler cache (https://parceljs.org/)
.parcel-cache .parcel-cache

View File

@ -0,0 +1 @@
PUBLIC_KEY=""

View File

@ -2,6 +2,14 @@ import React from 'react'
import { Community } from '@status-im/react' import { Community } from '@status-im/react'
export const App = () => { const publicKey = process.env.PUBLIC_KEY
return <Community publicKey="<YOUR_COMMUNITY_KEY>" theme="light" />
if (!publicKey) {
throw new Error(
'Add PUBLIC_KEY to your environment variables (see .env.example)'
)
}
export const App = () => {
return <Community publicKey={publicKey} theme="light" />
} }