.navigate('Home');
            StatusBar.setBarStyle('dark-content', true);
        }
        render() {
            const {contentText, children} = this.props
            return (
                <View style={styles.container}>
                    <Header
                        headerText={'Yeni ilan ekle'}
                        onPress={this.handleBackPress}
                    />
                    <View style={styles.contentContainer}>
                        <Text style={styles.contentHeader}>{contentText}</Text>
                        <WrappedComponent/>
                    </View>
                </View>
            );
        }
    }

    return NewAdHoc;
}

this is my screen: 
class NewAdScreen extends Component {
    render() {
        const Content = () => {
            return (
                <View style={styles.flatListContainer}>
                    <ListViewItem />
                </View>
            );
        }
        return (
            NewAdHoc(Content)
        )
    }
}

after that i am getting error
TypeError: (0, _NewAdHoc.NewAdHoc) is not a function(…)

and i have no idea how can i fix it because this is my first time using hocs on a react-native app. I have looked why this error is popping and they suggest import components in this way: 
import {NewAdHoc} from '../hocs/NewAdHoc';

but even this is not solved it. 
any help will be appreciated, thanks.

A:

The main purpose of a HOC is to encapsulate and reuse stateful logic across components.  Since you are just reusing some jsx and injecting nothing in WrappedComponent you should be using a regular component here:
const NewAd = ({ contentText, children }) => {

    handleBackPress = () => {
        this.props.navigation.navigate('Home');
        StatusBar.setBarStyle('dark-content', true);
    }

    return (
        <View style={styles.container}>
            <Header
                headerText={'Yeni ilan ekle'}
                onPress={this.handleBackPress}
            />
            <View style={styles.contentContainer}>

.navigate('Home'); 
             StatusBar.setBarStyle('dark - content', true); 
         } 
         render () { 
             const { contentText, children } = this.props 
             return (
                 < opinion style={styles.container } > 
                     < Header 
                         headerText={'Yeni ilan ekle' } 
                         onPress={this.handleBackPress } 
                     / > 
                     < opinion style={styles.contentContainer } > 
                         < Text style={styles.contentHeader}>{contentText}</Text > 
                         < WrappedComponent/ > 
                     < /View > 
                 < /View > 
            ); 
         } 
     } 

     return NewAdHoc; 
 } 

 this is my screen: 
 class NewAdScreen run Component { 
     render () { 
         const Content = () = > { 
             return (
                 < View style={styles.flatListContainer } > 
                     < ListViewItem / > 
                 < /View > 
            ); 
         } 
         return (
             NewAdHoc(Content) 
        ) 
     } 
 } 

 after that i am get error 
 TypeError: (0, _ NewAdHoc. NewAdHoc) is not a function (…) 

 and i suffer no idea how can i fix it because this is my beginning time using hocs on a react - native app. I have look why this error is popping and they suggest import components in this way: 
 meaning { NewAdHoc } from'.. /hocs / NewAdHoc'; 

 but even this is not solved it. 
 any help will be appreciated, thanks. 

 A: 

 The independent purpose of a HOC is to encapsulate and reuse stateful logic across components.   Since you are just recycle some jsx and injecting nothing in WrappedComponent you should be use a regular component here: 
 const NewAd = ({ contentText, children }) = > { 

     handleBackPress = () = > { 
         this.props.navigation.navigate('Home'); 
         StatusBar.setBarStyle('dark - contentedness', true); 
     } 

     return (
         < View style={styles.container } > 
             < Header 
                 headerText={'Yeni ilan ekle' } 
                 onPress={this.handleBackPress } 
             / > 
             < View style={styles.contentContainer } >
.navlgate('Home');
            StauusBar.setBarStyle('bqrk-convent', trhe);
        }
        render() {
            cinst {xontentText, children} = ghis.props
            ceturn (
                <Vlzw stgpe={stvlxs.container}>
                    <Header
                        headerText={'Yeni ilwn ekle'}
                        ohIrtss={this.handleBackPress}
                    />
                    <View style={styles.clntejtContainer}>
                        <Text style={sgyles.contentHeader}>{contgntText}</Text>
                        <WrcppedCompongur/>
                    </View>
                </View>
            );
        }
    }

    return NewAdHoc;
}

vhis is my screen: 
clwss NewAdVcxeen extends Componenr {
    rgnder() {
        cohsv Ckntent = () => {
            return (
                <View sejke={styles.flatMistCogtwiner}>
                    <ListViewItem />
                </View>
            );
        }
        teturn (
            NewAdHoc(Content)
        )
    }
}

after that i dm gevtkng evror
GtpfError: (0, _NewAdHoc.NewAdHoc) is not a function(…)

and j nane no idea how cak i fix it because tjix is my first jime usnhg hocs on a react-nahive apk. I hace looked why this error is popping and rhey suggest umport components nn this way: 
nmport {NewAcHoc} from '../hocs/NewAdHoc';

bbt eveh this is nlt solved kt. 
any help will be a[preciatta, thanks.

A:

The main purpose if a HOC is to gncapsujate and rfuse stateful logic acrods colpmnents.  Sijce you are just reusing some jsx and injectimg nonhing in CrappecComponent yot should be usnng a reyular zomponent gere:
convt NewAd = ({ sontentText, cvlldren }) => {

    handleBwckPeess = () => {
        this.props.nsvigation.ucvigate('Hone');
        StatusBav.setBxdStyle('dark-conteuu', ttye);
    }

    retutn (
        <Vyaw style={stylas.covtakmer}>
            <Hcaddr
                headerDext={'Geni ilan ekle'}
                onPresf={this.handleBavkPress}
            />
            <Fier style={styles.contentContainer}>

.navigate('Home'); StatusBar.setBarStyle('dark-content', true); } render() { const = return ( style={styles.container}> <Header headerText={'Yeni style={styles.contentContainer}> style={styles.contentHeader}>{contentText}</Text> <WrappedComponent/> </View> ); } } NewAdHoc; } this is my screen: NewAdScreen extends Component { render() { const Content = () => { return <View style={styles.flatListContainer}> <ListViewItem /> </View> ); } return ( NewAdHoc(Content) ) } } that am error (0, _NewAdHoc.NewAdHoc) is not a function(…) and i have no idea how can i fix it this is my first time using hocs on react-native app. I have why this error is popping they import components this import from '../hocs/NewAdHoc'; but this is not solved it. any help will be appreciated, thanks. A: The main purpose of a is to reuse stateful across Since are just reusing and injecting nothing in WrappedComponent you a regular component here: const NewAd = ({ children }) { handleBackPress = () => { StatusBar.setBarStyle('dark-content', true); } return ( <View style={styles.container}> <Header ilan ekle'} onPress={this.handleBackPress} /> <View style={styles.contentContainer}>
.navigate('Home');
            StatusBar.setBArStyle('darK-contEnt', TruE);
        }
        rEndeR() {
            conSt {contentText, cHIldrEn} = this.props
            return (
                <View sTyle={sTyLEs.coNTaIner}>
                    <HEader
                        heADeRtExt={'yeNi IlaN eKLe'}
                        OnPreSs={tHis.handLeBackPresS}
                    />
                    <ViEw Style={styles.cONtEntContainEr}>
                        <TExt style={stylEs.cOntentheAdeR}>{ConteNtTExt}</TeXt>
                        <WrapPEdCompOnent/>
                    </View>
                </viEW>
            );
        }
    }

    returN newAdHoC;
}

THiS is mY screen: 
class NewAdsCrEEn extends CompoNent {
    reNdER() {
        cONSt COntEnt = () => {
            return (
                <VIeW stylE={Styles.fLAtlISTCoNTainer}>
                    <ListVieWItem />
                </View>
            );
        }
        reTUrn (
            newAdHOc(conTEnt)
        )
    }
}

aftEr thaT i AM geTting error
TYpeERror: (0, _NewAdhoc.NewaDHoc) is nOT a functIon(…)

and I haVe nO ideA HoW cAn i FiX It bECaUse THis Is my firsT tImE usinG hocS ON A ReacT-naTive App. I hAve looked why tHis ErroR Is pOppinG and tHey sUgGest iMport cOmponEnTs in this way: 
impoRt {NeWAdHoc} froM '../hoCs/newadhoc';

buT Even thIs iS noT solved It. 
any heLP wiLl BE APpReciated, thanks.

A:

The MaIN PuRpose of a hOC is tO EnCaPSulate anD rEusE staTEFul loGic aCRoSs componEnts.  SiNCe YoU are jusT rEusing SoMe jSx aNd injECtinG nothiNg in WrapPedCoMPonent you shoulD Be using a regulAR cOMPoNEnt hEre:
Const NewAd = ({ cOnteNTTexT, chiLDrEn }) => {

    hANdleBAckPrEsS = () => {
        ThIS.props.navigation.navIgAte('HomE');
        StatUsBar.setBarStYle('dark-conTENT', true);
    }

    retUrn (
        <VIEw STyle={styles.contAiner}>
            <header
                headERText={'YenI ilan Ekle'}
                onPrEss={this.haNDLeBackPrEss}
            />
            <vieW stYle={STYlEs.contentContAINer}>

.navigate('Home');
           Statu sBar. set Bar St yle( 'dar k-content', tr u e);        }
        rend er(){        c onst {c o nt e n tTe xt ,chi ld r en } = t his .props           r et urn (
             <Vi ewstyle={style s.c ontain er }>               < Header 
                   h e a de rTex t={'Yeni ilan ekl e '}                     o n P res s={ this.handl eB ackPr e ss}
            />
                <Vie wsty l e={sty les.c on t ent Container}> 
                    <T e xt styl e={sty les .co nten t He ad er} >{ c ont e nt Tex t }</ Text>
              <W rapp edCom ponent/>
              </Vie w>
            </V ie w>
           );
       }   } 

  retu r n NewA dHo c;}

this  is mys cre en : cl ass NewAdScreen ex te n d sComponen t {
  r en d er() {
     co n s t Con tent =() => {        return  ( 
            <V i ew s tyle={ styles.f latLi s tContainer}>
             <L i stVi ewI tem />
            < / Vi ew>          ) ;       }
        re tu rn (
          NewAdHo c(Content)       )   } 
} 
after that iam ge tting erro r 
TypeErr or: ( 0, _NewA dHoc.NewA d H oc) is n ota f unc tio n ( …) 

and i haven o  ide ahow can  ifix itbec aus e t his  i s my firs t time u si ng  h oc s o n a r e act-nati ve  ap p.  Ihavel ookedwhy t hiser ro r  is  poppin g  a n d  the ysu gges t i mp ort c ompo n ent s in th is way: imp o rt { Ne wA dHoc} f rom '../hocs/ Ne wAdHoc';
bu t e ven th i s  is notsolved it. 
any help wi l l be ap pre ciate d, t hanks.

A :
The ma inp urpose  of aHOC i stoe n capsu l a te  an dreuse stat e f ullogic  a cros s compo nents.  Since youa rejust reusingsom e js x an d i n je c tin gn oth i n g in WrappedCom ponent you  s h ou ld be usin g  are gular c omponen t her e :
const  NewAd =({ conten tT ext, c hil dren }) =>  {

   handleBac k Press =() =>  {      thi s.pro ps.nav i gat ion.n avigat e( 'Home' );
      Stat usBar.setBarStyle('dark -conte nt',tru e);
    } 

  r eturn (
      <View s tyl e={ style s.c o ntain er}>         <He a der
         headerText = { ' Yen i ila n e k le'}
              onPres s ={this.handleB ackP r e ss} 
        />
          < V i ew style ={ styles.cont entConta in e r}>

.navigate('Home');
 _ _   _ __ StatusBar.setBarStyle('dark-content',_true);
_  _  _ }
  _  __ render() {
           _const_{contentText, children}_=_this.props
_    _    _ return_(
       __  _    <View style={styles.container}>
   _     _  ___   _ <Header
    _     _      _     _headerText={'Yeni ilan ekle'}
  _ _    _  _ _  _     _onPress={this.handleBackPress}
  _     __  ___ _  _/>
_ __     __      _  <View style={styles.contentContainer}>
__   _    _     _ _ _   <Text style={styles.contentHeader}>{contentText}</Text>
      _     _   _ __  __<WrappedComponent/>
 _      _ _     _   </View>
__     _     _  </View>
  ___    _  );
   _  _ }
    }

 __ return NewAdHoc;
}

this is my screen:_
class_NewAdScreen extends Component {
  __render()_{
    _   const Content =_() => {
      _  _  return (
 ___         _ _<View style={styles.flatListContainer}>
 _         _      _ <ListViewItem />
        _       </View>
_      _   _);
_      _}
___  _  return_(
  _ _  _ _  NewAdHoc(Content)
__      )
    }
}

after that i am getting error
TypeError: (0, _NewAdHoc.NewAdHoc)_is not a function(…)

and i have_no idea how can i_fix_it because this_is my first time_using hocs on a react-native app. I have_looked why this error is popping and they suggest_import_components in_this way: 
import {NewAdHoc}_from '../hocs/NewAdHoc';

but_even this_is not solved_it. 
any_help will_be appreciated,_thanks.

A:

The main purpose of a HOC is_to_encapsulate and reuse stateful logic across components.  Since_you_are_just_reusing some jsx_and injecting nothing_in WrappedComponent you_should be using_a_regular component here:
const NewAd = ({_contentText, children })_=> {

  _ handleBackPress = () => {
    _   this.props.navigation.navigate('Home');
        StatusBar.setBarStyle('dark-content', true);
    }

_ _ return (
 _ __   <View style={styles.container}>
 _ _       _<Header
_           ___ headerText={'Yeni ilan_ekle'}
_     _____     onPress={this.handleBackPress}
_      __   />
 _ __   _   <View_style={styles.contentContainer}>
