6. REACTJS INSTALLATION
Create a project Directory
Change the Current Working Directory
Run npm init for creating package.json
Run npm install react --save
Verify node_modules directory
10. REACTJS INLINE STYLE
Key-value pair
var styleObject={
styleAttribute: "styleValue",
};
styleAttribute : camel case
styleValue: wrapped in double quotes
Example
11. REACTJS EVENT HANDLING
Similar to HTML DOM events
Difference in naming handlers
Handlers are camel case
onclick becomes onClick
Example
12. USEFUL NON-DOM ATTRIBUTES
key:
This is an optional attribute can be used for uniquely identify each component in the page.
ref:
This is an optional attribute that can be used to access the child element from outside of render()
method.
dangerouslySetInnerHTML:
This attribute can be used inside JSX element to set HTML content inside the component.
Example
17. REACTJS LIFECYCLE EXAMPLE
Let’s checkout an simple React Component <Welcome>
To determine the order of execution of these lifecycle methods
Example
18. STATEFUL CUSTOM COMPONENT
To refer the component state : this.states
To change the component state : this.setState(<object>)
Object: {key:value}
Example
19. PRECOMPILED JSX FOR PRODUCTION
Remove in browser JSX transformer
React-tools
npm install -g react-tools
Example