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

Separation of React logic and other #38

Open
trentgoing opened this issue Jul 10, 2020 · 0 comments
Open

Separation of React logic and other #38

trentgoing opened this issue Jul 10, 2020 · 0 comments

Comments

@trentgoing
Copy link

sliceQuestions(data) {
if (this.state.moreQuestions === 0) {
return data.slice(0, 2).sort(compareQuestions);
} else if (this.state.moreQuestions === 1) {
return data.slice(0, 4).sort(compareQuestions);
} else {
return this.state.questions;
}
}

As part of code cleanup, think about what logic is specific to your react components (state management, rendering) and what could be modularized into a helper function.

Beyond just making the component more concise and readable, this might also be easier to debug and test.

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

1 participant