GithubHelp home page GithubHelp logo

cra-project-structure's Introduction

React file structure example

Desired file structure

+-- src
|    |
|    +-- assets
|    |     |
|    |     +-- images
|    |     |   |         
│    |     |   +-- image.png
|    |     |   +-- image.jpg
|    |     |   +-- image.svg
|    |     |
|    |     +-- icons
|    |     |   |  
│    |     |   +-- icon.png
|    |     |   +-- icon.jpg
|    |     |   +-- icon.svg
|    |     |
|    +-- components
│    |     |
|    |     +-- SomeComponent
|    |     |  |
|    |     |  +-- Child
|    |     |  |   +-- styles.ts
|    |     |  |   +-- SomeComponentChild.tsx
|    |     |  |
|    |     |  +-- SomeComponent.tsx
|    |     |  +-- types.ts
|    |     |  +-- styles.ts
|    |     |  +-- utils.ts
|    |     |  +-- selectors.ts
|    |     |  +-- index.ts
|    |     |
|    |     +-- AnotherComponent.tsx
|    |     |
|    |     +-- index.ts
|    | 
|    +-- hooks
|    |     |
|    |     +-- useFirsHook.ts
|    |     +-- useSecondHook
|    |     +-- index.ts
|    |
|    +-- pages
|    |     |
|    |     +-- PageComponent
|    |     |   |
|    |     |   +-- PageComponent.ts
|    |     |   +-- styles.ts
|    |     |   +-- index.ts
|    |     |
|    |     +-- AnotherPageComponent.tsx
|    |     +-- index.ts
|    |
|    +-- service
|    |     |
|    |     +-- SomeService
|    |     |   |
|    |     |   +-- constants.ts
|    |     |   +-- SomeService.ts
|    |     |   +-- types.ts
|    |     |   +-- index.ts
|    |     |
|    |     +-- AnotherService.tsx
|    |     |
|    |     +-- index.ts
|    |
|    +-- state
|    |     |
|    |     +-- branchName
|    |     |   |         
│    |     |   +-- actions.ts
|    |     |   +-- actionTypes.ts
|    |     |   +-- reducer.ts
|    |     |   +-- selectors.ts
|    |     |   +-- index.ts
|    |     |
|    |     +-- index.ts
|    |
|    +-- utils
|    |     |
|    |     +-- utilsName.ts
|    |     |
|    |     +-- index.ts

Constants folder

As you can see there is no constants folder because of intersection with Node.js internal module constants package

cra-project-structure's People

Contributors

drobenyuka avatar

Watchers

James Cloos avatar  avatar

cra-project-structure's Issues

Working with apis

I don't think using pure fetch or axios is the best way for api integration nowadays. Using redux toolkit query or react query would be more suitable. Redux toolkit query would be more effective because in the future we are planning of using redux toolkit. Toolkit and toolkit query have saga, thunk integration, cache, by default storing data to the redux store and many more advantages.

Common

I would like to suggest creating common folder.
folder structure:
common
-hooks
--index.ts
-utils
--index.ts
-api
--index.ts
-assets
--index.ts
-components
--index.ts
-modules
--index.ts
-models(ts types)
--index.ts
-constants
--index.ts
-helpers
--index.ts
-store
--index.ts

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.