What is the quickest way to convert a React app to React Native?

后端 未结 6 1644
死守一世寂寞
死守一世寂寞 2020-12-08 00:06

This may be a naive question, but I couldn\'t find too much information on this topic. I have a fully functional react-redux application and I would now like to port it to

6条回答
  •  北海茫月
    2020-12-08 00:48

    Some of the reusable things are styles:

    var style = {
         box: {height: 30, width: 30, padding: 10, ect...}
    }
    

    Logic such as state :

    constructor(props){
     super(props);
    
     this.state= {text: "hi"};
    }
    

    the state can be shared between navite and dom like so

    
    this.state.text
    
    

    dom looks like this

    this.state.text

    You can even share functions but you have to be careful like it was stated above, as long as you're not directly invoking any dom or refs in your logic.

    onClick(){
     this.setState({text: "good bye"});
    }
    

提交回复
热议问题