javascript - Creating a global modal using react-redux and foundation reveal -


i'm creating modal displays information specific user , it's triggered clicking on picture. modal should able fire different components. approach follows (i use react redux):

  1. create store "modal" property that's set reducer "modalreducer"

    modal: modalreducer 
  2. modal object following properties: showmodal=false, user=undefined, image=undefined

  3. when div containing picture clicked, action being dispatched sets showmodal true (with username , url image link arguments).

export var openmodal = (user, image) => { return { type: 'open_modal', user, image } }

  1. for actual modal use foundation reveal modal , in render method check if modal.showmodal == true , use jquery open up.

now, toggling modal works charm cannot use modal.user , modal.image properties inside of render method prints following error message:

uncaught error: findcomponentroot(..., .0.2.0.0.1): unable find element. means dom unexpectedly mutated (e.g., browser), due forgetting when using tables, nesting tags ,

, or , or using non-svg elements in parent. try inspecting child nodes of element react id ``.

i'm problem lies within profilemodal.jsx component. idea i'm doing wrong?

export class profilemodal extends react.component {   componentdidmount () {     var elem = new foundation.reveal($('#profile-modal'));     $('#profile-modal').on('closed.zf.reveal',()=>{this.props.dispatch(actions.hidemodal())});   }   render () {     var {modal} = this.props;     if (modal.showmodal) {       $('#profile-modal').foundation('open');     }       return(         <div>           <div id="profile-modal" classname="reveal large">             <div classname="modal-container">               <div classname="modal-picture" style={{backgroundimage: `url(${modal.image})`}}></div>               <p>{modal.user}</p> ... 


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -