diff --git a/anti-patterns/README.md b/anti-patterns/README.md index 7215f31..df02400 100644 --- a/anti-patterns/README.md +++ b/anti-patterns/README.md @@ -1,3 +1,3 @@ -# Anti-pattens +# Anti-patterns -Familiarizing ourselves with common anti-patterns will help us understand how React works and describe useful forms of refactoring our code. \ No newline at end of file +Familiarizing ourselves with common anti-patterns will help us understand how React works and describe useful forms of refactoring our code. diff --git a/conventions/08.closures-in-render.md b/conventions/08.closures-in-render.md index 2987460..3ac80d5 100644 --- a/conventions/08.closures-in-render.md +++ b/conventions/08.closures-in-render.md @@ -4,19 +4,21 @@ Avoid passing new closures to subcomponents. Here’s why: - every time the parent component renders, a new function is created and passed to the input. -- If the input were a React component, this would automatically trigger it to re-render, regardless of whether its other props have actually changed. +- If the input was a React component, this would automatically trigger it to re-render, regardless of whether its other props have actually changed. - Reconciliation is the most expensive part of React. Don’t make it harder than it needs to be! Plus, passing a class method is easier to read, debug, and change. ```javascript class Example extends Component { render() { - { model.name = e.target.value }} - // ^ Not this. Use the below: - onChange={this.handleChange} - placeholder="Your Name"/> + return ( + { model.name = e.target.value }} + // ^ Not this. Use the below: + onChange={this.handleChange} + placeholder="Your Name"/> + ) } } ``` diff --git a/patterns/05.children-types.md b/patterns/05.children-types.md index ebd5830..1080bb2 100644 --- a/patterns/05.children-types.md +++ b/patterns/05.children-types.md @@ -23,7 +23,7 @@ function render() { function render() {