can't load saved design

This issue has been tracked since 2021-09-05.

the editorRef.current.editor doesn't has a object saveDesign but it is there in the editorRef.current ...
the problem is that i cant load design with json saved data from database
I am using it inside a shopify app inside a next page

code to save in mongodb realm

if(saveTemplateName.length===0)
                {
                    setShow(true)
                    return
                }
                emailEditorRef.current.saveDesign(async (design)=>{
                const app = Realm.App.getApp(process.env.NEXT_PUBLIC_REALM_APP_ID); 
                const mongodb = app.currentUser.mongoClient("mongodb-atlas");
                const emailTemplatesDB = mongodb.db("test").collection("emails")
                await emailTemplatesDB.updateOne(
                    {savedname:saveTemplateName},
                    {$set:{savedtemplate:design}}
                )

code to load data

 const emailSaveRef = useRef(null)

 const [design,setDesign] = useState({})

 useEffect(()=>{
    (async function(){
      const app=new Realm.App({id:process.env.NEXT_PUBLIC_REALM_APP_ID})
      const credentials = Realm.Credentials.anonymous();
      await app.logIn(credentials)
      const mongodb = app.currentUser.mongoClient("mongodb-atlas") 
      const emailTemplatesDB = mongodb.db("test").collection("emails")
    //   console.log(name)
      const data = await emailTemplatesDB.findOne({savedname:name}) //name is received through query 
      if (data){
        // console.log('fetch design',data.savedtemplate)
        setDesign(data.savedtemplate)
      }
    })()
  },[])
 const onLoad = () => {
        emailSaveRef.current.loadDesign(design);
    };

but it always renders a empty design ....

driaug wrote this answer on 2022-07-14

I had this problem with Next.js today.
I could load designs on localhost but they were not loading on production.

The fix was changing the deprecated onLoad to the new onReady function.

More Details About Repo
Owner Name unlayer
Repo Name react-email-editor
Full Name unlayer/react-email-editor
Language JavaScript
Created Date 2017-10-01
Updated Date 2022-12-05
Star Count 3598
Watcher Count 48
Fork Count 627
Issue Count 163

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date