i know it's minor , maybe fool question i'm stuck hour @ error cant see. code:
const modalroot = ({ modaltype, modalprops, locale }) => { if (!modaltype) { return <span />; } return ( <intlprovider locale={locale} key={locale} messages={messagesfor(locale)} > <div classname="backdrop"> {renderappropriatemodal(modaltype, modalprops)} </div> </intlprovider> ); };
the console shows error in if saying unexpected token. why happening??
this can error...
check samples.
wrong place declare.
import react 'react'; class yourclass extends react.component { constructor(props) { super(props); } //do not place modalroot here const modalroot = ({ modaltype, modalprops, locale }) => { //contents } render(){ return( <div>{yourcontent}</div> ); } }
right place declare
import react 'react'; //place here outside class yourclass const modalroot = ({ modaltype, modalprops, locale }) => { //contents } class yourclass extends react.component { constructor(props) { super(props); } render(){ return( <div>{yourcontent}</div> ); } }
if still intends inside class... better use function instead...
import react 'react'; class yourclass extends react.component { constructor(props) { super(props); } //function type modalroot modalroot(modaltype, modalprops, locale){ //contents return <intlprovider />; } render(){ const {modaltype, modalprops, locale} = this.props; let yourcontent = this.modalroot(modaltype, modalprops, locale); return( <div>{yourcontent}</div> ); } }
hope helps...
Comments
Post a Comment