Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
ReactJS by Example - Building Modern Web Applications with React

You're reading from  ReactJS by Example - Building Modern Web Applications with React

Product type Book
Published in Apr 2016
Publisher Packt
ISBN-13 9781785289644
Pages 280 pages
Edition 1st Edition
Languages
Author (1):
Vipul A M Vipul A M
Profile icon Vipul A M

Table of Contents (20) Chapters

ReactJS by Example - Building Modern Web Applications with React
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
1. Getting Started with React 2. JSX in Depth 3. Data Flow and Life Cycle Events 4. Composite Dynamic Components and Forms 5. Mixins and the DOM 6. React on the Server 7. React Addons 8. Performance of React Apps 9. React Router and Data Models 10. Animation 11. React Tools 12. Flux 13. Redux and React Index

State versus props


"Shawn, it's important to understand the difference between props and state and where to use what." informed Mike.

"Props are immutable. They should not be updated by the component to which they are passed. They are are owned by the component which passes them to some other component. State is something internal and private to the component. State can and will change depending on the interactions with the outer world." said Mike.

"State should store as simple data as possible, such as whether an input checkbox is checked or not or a CSS class that hides or displays the component." Mike added.

"Another thing to make sure is to not duplicate props in state." said Mike.

var App = React.createClass({
  getInitialState: function() {
    return {
      changeSets: this.props.changeSets
    };
  }
});

"It is possible to set the state based on data passed in props. However, the parent component can update the props and send them again. In this case, the state will be muddled up with...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}