Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documenting the application state #2195

Closed
vraa opened this issue Jan 10, 2017 · 3 comments
Closed

Documenting the application state #2195

vraa opened this issue Jan 10, 2017 · 3 comments

Comments

@vraa
Copy link

vraa commented Jan 10, 2017

I am working on a React / Redux web application. In the beginning of the project, I had a very good understanding of my application state. But, as the code base grows, I tend to put more and more attributes to the application state through reducers. The problem here is, if a new person joining my project, he may not have a clear knowledge about all the attributes that are already there in the state.

Right now, I am just using a commented out Object in a file called state.js to describe all the attributes in the state.

/*
    APP_STATE = {
        attribute1 : '',
        attribute2 : '',
        attribute3 : [],
        attribute4 : {
            key: ''
        },
    }
*/

The question is: Is there better way to document the structure of my application state so that it is easy to make sense? What approach do you guys use?

@JacobSoderblom
Copy link

JacobSoderblom commented Jan 17, 2017

Depending on your structure, I think wp-calypso does a great job on that. They have selectors, reducers, constants, actions and a README.md file that holds most of the documentation, all of them in same dir. Look below!

state
  product
    reducer.js
    selectors.js
    actions.js
    constants.js
    README.md

Check them out!

@vraa
Copy link
Author

vraa commented Jan 17, 2017

@JacobSoderblom that's interesting. May be a similar approach with reduced complexity and structure will work for small scale apps. Thanks.

@timdorr
Copy link
Member

timdorr commented Jan 23, 2017

You can always use a Redux devtool, like either redux-devtools or redux-devtools-extension to browse the state tree. You can also just JSON.stringify the state at any point (I suggest putting the store on window to make it accessible through your console) to see what it looks like.

@timdorr timdorr closed this as completed Jan 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants