Skip to content

Commit

Permalink
fix errors and remin env name
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaRotimi committed Oct 19, 2023
1 parent 18c629c commit 870e713
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/nextjs-upload-formdata/pages/api/upload.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import formidable from 'formidable';
import { v2 as cloudinary } from 'cloudinary';

// Store environment variables in your .env.local file
// Store environment variables in your .env file
cloudinary.config({
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
secure: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import {useEffect, useRef} from "react";
let cloudinary;

const UploadWidget = ({ children, onUpload }) => {
/**
* handleOnLoad
* @description Stores the Cloudinary window instance to a ref when the widget script loads
*/
const widget = useRef();

useEffect(() => {
handleOnLoad();

return () => {
widget.current?.destroy();
widget.current = undefined;
}
}, [])

/**
* handleOnLoad
* @description Stores the Cloudinary window instance to a ref when the widget script loads
*/

function handleOnLoad() {
if ( !cloudinary ) {
cloudinary = window.cloudinary;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const UploadWidget = ({ children, onUpload }) => {
const widget = useRef();

useEffect(() => {
handleOnLoad();

return () => {
widget.current?.destroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function UploadWidget({ children, onUpload }) {
// "unsigned" uploads which may allow for more usage than intended. Read more
// about unsigned uploads at: https://cloudinary.com/documentation/upload_images#unsigned_upload

const cloudName = ENV.CLOUD_NAME;
const cloudName = ENV.CLOUDINARY_CLOUD_NAME;
const uploadPreset = ENV.CLOUDINARY_UPLOAD_PRESET;
if (!cloudName || !uploadPreset) {
console.warn(`Kindly ensure you have the cloudName and UploadPreset
Expand Down Expand Up @@ -83,7 +83,7 @@ function UploadWidget({ children, onUpload }) {
}

/**
* Do not render the component if the clodinary script is not loaded
* Do not render the component if the cloudinary script is not loaded
*/
return children({
cloudinary,
Expand Down
2 changes: 1 addition & 1 deletion examples/remix-upload-widget-preset/app/root.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function links() {

export function loader() {
const ENV = {
CLOUD_NAME: process.env.CLOUDINARY_CLOUD_NAME ?? "",
CLOUDINARY_CLOUD_NAME: process.env.CLOUDINARY_CLOUD_NAME ?? "",
CLOUDINARY_UPLOAD_PRESET: process.env.CLOUDINARY_UPLOAD_PRESET ?? "",
};
return json({ ENV });
Expand Down

0 comments on commit 870e713

Please sign in to comment.