Skip to content

Commit

Permalink
Markdown updates
Browse files Browse the repository at this point in the history
  • Loading branch information
vasanthk committed Apr 9, 2017
1 parent 4ce7453 commit ee1608b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 29 deletions.
14 changes: 7 additions & 7 deletions patterns/28.decorators.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ export default class ProfileContainer extends Component {
// Component code
}
```
Check for a Decorator usage example [here](https://github.com/gigobyte/react-document-title-decorator)

### Article:
- https://medium.com/@gigobyte/enhancing-react-components-with-decorators-441320e8606a
- [Enhancing React components with Decorators](https://medium.com/@gigobyte/enhancing-react-components-with-decorators-441320e8606a)

### Related:
- https://twitter.com/dan_abramov/status/628202050946514944
- http://stackoverflow.com/questions/36553814/what-is-the-use-of-connect-decorator-in-react-redux
- http://stackoverflow.com/questions/36286384/decorators-with-react-components
- https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841#.8cbzw5wcl
- https://survivejs.com/react/appendices/understanding-decorators/
- [Decorators != higher ordered components](https://twitter.com/dan_abramov/status/628202050946514944)
- [React Decorator example - Module](https://github.com/gigobyte/react-document-title-decorator)
- [What is the use of Connect(decorator in react-redux)](http://stackoverflow.com/questions/36553814/what-is-the-use-of-connect-decorator-in-react-redux)
- [Decorators with React Components](http://stackoverflow.com/questions/36286384/decorators-with-react-components)
- [Exploring ES7 decorators](https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841#.8cbzw5wcl)
- [Understanding Decorators](https://survivejs.com/react/appendices/understanding-decorators/)
7 changes: 3 additions & 4 deletions patterns/29.feature-flags-using-redux.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Feature Flags
Enabling Feature flags in React using Redux

### Reference:
- http://blog.rstankov.com/feature-flags-in-react/
- https://gist.github.com/RStankov/0e764f27daf38f2fcd81b82360334528

```javascript
// createFeatureFlaggedContainer.js
import React from 'react';
Expand Down Expand Up @@ -109,3 +105,6 @@ export isFeatureEnabled({ features }, featureName) {
return isFeatureEnabledSelector(features, featureName);
}
```
### Reference:
- http://blog.rstankov.com/feature-flags-in-react/
- https://gist.github.com/RStankov/0e764f27daf38f2fcd81b82360334528
6 changes: 3 additions & 3 deletions patterns/30.component-switch.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# The switching component
A switching component is a component that renders one of many components.

### Reference:
- https://hackernoon.com/10-react-mini-patterns-c1da92f068c5

Use an object to map prop values to components
```javascript
import HomePage from './HomePage.jsx';
Expand All @@ -28,3 +25,6 @@ Page.propTypes = {
page: PropTypes.oneOf(Object.keys(PAGES)).isRequired
};
```

### Reference:
- https://hackernoon.com/10-react-mini-patterns-c1da92f068c5
7 changes: 3 additions & 4 deletions patterns/31.reaching-into-a-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
Accessing a component from the parent.
eg. Autofocus an input (controlled by parent component)

### Reference:
- https://hackernoon.com/10-react-mini-patterns-c1da92f068c5


#### Child Component
An input component with a focus() method that focuses the HTML element
```javascript
Expand Down Expand Up @@ -45,3 +41,6 @@ class SignInModal extends Component {
}
}
```
### Reference:
- https://hackernoon.com/10-react-mini-patterns-c1da92f068c5

8 changes: 4 additions & 4 deletions patterns/32.list-components.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Lists Components
Lists and other things that are almost components

### Reference:
- https://hackernoon.com/10-react-mini-patterns-c1da92f068c5


Instead of making a separate component for lists I can then generate the results like:
```javascript
const SearchSuggestions = (props) => {
Expand All @@ -24,3 +20,7 @@ const SearchSuggestions = (props) => {
If things get more complex or you want to use this component elsewhere,
you should be able to copy/paste the code out into a new component.
Don’t prematurely componentize.

### Reference:
- https://hackernoon.com/10-react-mini-patterns-c1da92f068c5

13 changes: 6 additions & 7 deletions patterns/33.format-text-via-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
Instead of formatting text by calling helper functions inside render, we can create a separate component that
handles this.

### Reference:
- https://hackernoon.com/10-react-mini-patterns-c1da92f068c5



#### WITH COMPONENT
#### With Component
Render function is lot cleaner to comprehend as it is just simple component composition.
```javascript
const Price = (props) => {
Expand Down Expand Up @@ -56,7 +51,7 @@ const Page = () => {
);
};
```
#### WITHOUT COMPONENT
#### Without Component
Less code: But render looks less clean. (Debatable, yeah I understand)
```javascript
function numberToPrice(num, options = {}) {
Expand Down Expand Up @@ -86,3 +81,7 @@ const Page = () => {
);
};
```

### Reference:
- https://hackernoon.com/10-react-mini-patterns-c1da92f068c5

0 comments on commit ee1608b

Please sign in to comment.