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

Restructure the project #48

Open
ivgraai opened this issue Jun 5, 2020 · 6 comments
Open

Restructure the project #48

ivgraai opened this issue Jun 5, 2020 · 6 comments
Labels
help wanted Extra attention is needed prio 1 High priority story-point: 8 This rates the relative effort of work technical debt Code smells, higher levels of complexity etc.
Milestone

Comments

@ivgraai
Copy link
Owner

ivgraai commented Jun 5, 2020

No description provided.

@ivgraai ivgraai added prio 1 High priority technical debt Code smells, higher levels of complexity etc. labels Jun 5, 2020
@ivgraai
Copy link
Owner Author

ivgraai commented Jun 5, 2020

  • E.g. use Redux more times

@ivgraai
Copy link
Owner Author

ivgraai commented Jun 9, 2020

  • E.g. useEffect, useState
  • Or React.PureComponent

@ivgraai
Copy link
Owner Author

ivgraai commented Jun 10, 2020

  • E.g. delete unused components
  • And move DbHelper into services

@ivgraai ivgraai modified the milestones: Sprint 5, Sprint 4 Jun 11, 2020
@ivgraai ivgraai pinned this issue Jun 11, 2020
@ivgraai ivgraai self-assigned this Jun 12, 2020
ivgraai added a commit that referenced this issue Jun 12, 2020
ivgraai added a commit that referenced this issue Jun 17, 2020
@ivgraai ivgraai added the story-point: 8 This rates the relative effort of work label Jun 19, 2020
@ivgraai ivgraai assigned ivgraai and unassigned ivgraai Jun 21, 2020
@ivgraai ivgraai added the wip Work in progress label Jun 23, 2020
ivgraai added a commit that referenced this issue Jun 23, 2020
ivgraai added a commit that referenced this issue Jun 23, 2020
ivgraai added a commit that referenced this issue Jun 25, 2020
@ivgraai ivgraai added help wanted Extra attention is needed and removed wip Work in progress labels Jun 25, 2020
@ivgraai
Copy link
Owner Author

ivgraai commented Jun 25, 2020

React.PureComponent implements it with a shallow prop and state comparison. (value and memory address checks)

If your React component’s render() function renders the same result given the same props and state, you can use React.PureComponent for a performance boost in some cases.

Only use React pure component when the React component won’t be mutated by state or props.

Also, if you plan to use React children components inside your pure component, make sure those children components are pure as well.

Functional components are ones that don't have lifecycle functions. They're supposedly stateless, but they're so nice and clean that we now have hooks (since React 16.8) so you can still have a state. So I guess they're just "clean components".

That being said, you will gain much more from using PureComponent in your root level nodes (i.e. PureComponent will not improve overall performance as much in leaf level components because it only saves renders from that component).

PureComponent is only great with simple flat objects/props or by using something like ImmutableJS to detect changes in any object with a simple comparison.

Interesting patterns

ivgraai added a commit that referenced this issue Jun 26, 2020
@ivgraai
Copy link
Owner Author

ivgraai commented Jun 26, 2020

Go with functional if your component doesn't do much more than take in some props and render. You can think of these as pure functions because they will always render and behave the same, given the same props. Functional Components mainly focuses on the UI of the application, not on the behaviour. Class components are used as container components to handle state management and wrap child components.

Stateless functions are the "functional components". Hooks are predefined functions that can be used inside a function component to enhance it with state, life cycle management, etc.

They can be used, if you don't need state and lifecycle methods, etc. Furthermore they can be turned into stateFUL function components by using hooks. Function instead of class, no this, no render function, just return, reuse code more easily by importing functions and using it inside the component

Class based components:
state
lifecycle methods
memoization with React.PureComponent

Functional components:
state (useState, useReducer hooks)
lifecycle methods (via the useEffect, useLayoutEffect hooks)
memoization via the memo HOC

Why do I prefer Funtional components?
React provide the useEffect hook which is a very clear and concise way to combine the componentDidMount, componentDidUpdate and componentWillUnmount lifecycle methods.
With hooks you can extract logic that can be easily shared across components and testable.
Less confusion about the scoping.

ivgraai added a commit that referenced this issue Jun 26, 2020
@ivgraai ivgraai removed their assignment Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed prio 1 High priority story-point: 8 This rates the relative effort of work technical debt Code smells, higher levels of complexity etc.
Projects
None yet
Development

No branches or pull requests

1 participant