0

I'm struggling with folder structure of my react native app. My app is a simple form app and doesn't use redux. My folder structure is below:

App.js
index.js
package.json

Yes, I didn't add any files... I searched on google, but I found only folder structure with redux. I wrote almost all my code in App.js, but I think it is becoming complex a bit. I want to know where to move logics from App.js.

My App.js is like this:

some import codes here

export default class App extends Component{
  super()
  this.state={//init state}

  initState(){
    //initialize state
    //this is called when the submit button is pushed
  }

  onPress(){
    //this function is called when the submit button is pushed
  }

 render(){
   return(
     //a lot of inputs here like id, name, email, date, comment...
     //I think I can divide these inputs as components
   )
 }

 const styles = StyleSheet.create({
   //style sheets here
 })
}

I want to know

  • Where to put my "onPress" or "initState" or some other functions.
  • How to divide simple form inputs to components
  • Whether I can remove stylesheets from App.js or not and where to put them

Thanks.

2

1 Answer 1

1

I have worked on several apps with different different folder structure with or without redux. But I found this folder structure very helpful.This structure also helps in large scale application as well for small scale applications.

Fractal — A react app structure for infinite scale

https://hackernoon.com/fractal-a-react-app-structure-for-infinite-scale-4dab943092af

Sign up to request clarification or add additional context in comments.

1 Comment

I liked the way this is structured, even i used this for few of my projects. I really liked medium.com/@alexmngn/… also though. Do give it a read.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.