11import React from 'react' ;
22import './App.css' ;
3- import { IKImage , IKContext , IKUpload } from 'imagekit -react'
3+ import { IKImage , IKContext , IKUpload } from 'imagekitio -react'
44function App ( ) {
55 const publicKey = process . env . REACT_APP_PUBLIC_KEY ;
6- const urlEndpoint = process . env . REACT_APP_URL_ENDPOINT ;
6+ let urlEndpoint = process . env . REACT_APP_URL_ENDPOINT ;
7+ if ( urlEndpoint [ urlEndpoint . length - 1 ] === "/" )
8+ urlEndpoint = urlEndpoint . slice ( 0 , urlEndpoint . length - 1 ) ;
9+
710 const authenticationEndpoint = process . env . REACT_APP_AUTHENTICATION_ENDPOINT ;
811
12+ let path = "/default-image.jpg" ;
13+ if ( path [ 0 ] === "/" )
14+ path = path . split ( "/" ) [ 1 ] ;
15+
16+ const src = `${ urlEndpoint } /${ path } ` ;
17+
918 return (
1019 < div className = "App" >
1120 < h1 > Hi! This is an ImageKit React SDK Demo!</ h1 >
1221 < p > Let's add an Image</ p >
13- < IKImage publicKey = { publicKey } urlEndpoint = { urlEndpoint } src = "https://ik.imagekit.io/gqyojxcwzxj/ABC_BV8lzpfOS" />
22+ < IKImage publicKey = { publicKey } urlEndpoint = { urlEndpoint } src = { src } />
1423 < p > Let's transform this once</ p >
15- < IKImage publicKey = { publicKey } urlEndpoint = { urlEndpoint } src = "https://ik.imagekit.io/gqyojxcwzxj/ABC_BV8lzpfOS" transformation = { [ {
24+ < IKImage publicKey = { publicKey } urlEndpoint = { urlEndpoint } src = { src } transformation = { [ {
1625 "height" : "200" ,
1726 "width" : "200"
1827 } ] } />
1928 < p > Let's transform this more than once</ p >
20- < IKImage publicKey = { publicKey } urlEndpoint = { urlEndpoint } path = "/ABC_BV8lzpfOS" transformation = { [ {
29+ < IKImage publicKey = { publicKey } urlEndpoint = { urlEndpoint } path = { path } transformation = { [ {
2130 "height" : "200" ,
2231 "width" : "200" ,
2332 } ,
@@ -26,14 +35,14 @@ function App() {
2635 } ] } />
2736 < p > Adding a Image with Context</ p >
2837 < IKContext publicKey = { publicKey } urlEndpoint = { urlEndpoint } >
29- < IKImage path = "/ABC_BV8lzpfOS" transformation = { [ {
38+ < IKImage path = { path } transformation = { [ {
3039 "height" : "300" ,
3140 "width" : "400"
3241 } ] } />
3342 </ IKContext >
3443 < p > LQIP</ p >
3544 < IKContext publicKey = { publicKey } urlEndpoint = { urlEndpoint } >
36- < IKImage path = "/ABC_BV8lzpfOS" lqip = { { active : true , quality : 30 } } />
45+ < IKImage path = { path } lqip = { { active : true , quality : 30 } } />
3746 </ IKContext >
3847 < p > Upload</ p >
3948 < IKContext publicKey = { publicKey } urlEndpoint = { urlEndpoint } authenticationEndpoint = { authenticationEndpoint } >
@@ -45,3 +54,4 @@ function App() {
4554}
4655
4756export default App ;
57+
0 commit comments