Skip to content

Commit ceaf5a7

Browse files
committed
fixed css
1 parent 034e095 commit ceaf5a7

File tree

11,864 files changed

+1179848
-820
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

11,864 files changed

+1179848
-820
lines changed

_includes/head.html

+4
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,8 @@
8787
<link rel="stylesheet" href="{{ "/assets/fonts/font-awesome/css/font-awesome.min.css" | prepend: site.baseurl }}">
8888
<!-- Styles -->
8989
<link rel="stylesheet" href="{{ "/assets/css/main.css" | prepend: site.baseurl }}">
90+
91+
<link rel="stylesheet" href="{{ "/assets/css/prism.css" | prepend: site.baseurl }}">
92+
93+
<script src="{{ "/assets/js/prism.js" | prepend: site.baseurl }}"></script>
9094
</head>

_posts/2018-05-1-react-concepts-and-getting-start.markdown

+22-21
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,46 @@ tags: [react, reactjs, learn react]
99

1010
Well, before we start building anything meaningful, its important that we cover some base concepts first, so lets getting start.
1111

12-
### What is React?
1312

14-
React is a UI library developed at Facebook to facilitate the creation of interactive, stateful and reusable UI components. It is used at Facebook in production, and Instagram.com is written in React.
13+
## What is React?
14+
15+
React is a UI library developed at Facebook to facilitate the creation of interactive, stateful and reusable UI components. It is used at Facebook in production, and Instagram is written in React.
1516

1617
One of it’s unique points is that not only does it perform on the client side, but it can also be rendered server side, and they can work together inter-operably.
1718

18-
### Concepts
19+
## Concepts
1920

2021
React has quite a small API. This makes it fun to use, easy to learn, and simple to understand. However, being simple does not mean it’s familiar. There are a few concepts to cover before getting started. Let’s look at each in turn:
2122

22-
#### React Elements
23+
### React Elements
2324

2425
React elements are JavasScript objects which represent HTML elements. They don’t exist in the browser. They represent browser elements such as an h1, div or section.
2526

26-
#### JSX
27+
### JSX
2728

2829
JSX is a technique for creating React elements and components.
2930

30-
#### Virtual DOM
31+
### Virtual DOM
3132

3233
The Virtual DOM is a JavaScript tree of React elements and components. React render the Virtual DOM to the browser to make the user interface visible. React observes the Virtual DOM for changes and automatically mutates browser DOM to mach the Virtual DOM.
3334

3435
With a small understanding of these concepts we can move to using React. We will build a series of user interfaces, each adding a layer of functionality on the previous. We will build a photo stream similar to instagram.
3536

36-
#### Rendering
37+
### Rendering
3738

3839
The first order of business is rendering a virtual element (a React element or component). Remember, since a virtual element exists only in JavaScript memory, we must explicitly tell React to render it to the browser DOM.
3940

40-
```
41+
```javascript
4142
React.render(<img src='src/logo.png' />, document.body);
4243
```
4344

4445
The render function accepts two arguments, a virtual element and a real DOM node. React takes the virtual element and inserts it into the given DOM node.
4546

46-
#### Components
47+
### Components
4748

4849
Components are the heart and soul of React. They are custom React elements. They are usually extended with unique functionality and structure.
4950

50-
```
51+
```javascript
5152
var Photo = React.createClass({
5253
render: function() {
5354
return <img src='src/logo.png' />;
@@ -63,11 +64,11 @@ The Photo component is constructed and rendered to the document body.
6364

6465
This component does nothing more than the previous React image element but it’s ready to be extended with custom functionality and structure.
6566

66-
#### Props
67+
### Props
6768

6869
Props can be thought of as a component’s options. They are given as arguments to a component and look exactly like HTML attributes.
6970

70-
```
71+
```javascript
7172
var Photo = React.createClass({
7273
render: function() {
7374
return (
@@ -82,11 +83,11 @@ var Photo = React.createClass({
8283
React.render(<Photo imageURL='src/logo.png' caption='Phnom Penh, Cambodia' />, document.body);
8384
```
8485

85-
#### Specs, Lifecycle & State
86+
### Specs, Lifecycle & State
8687

8788
The render method is the only required spec for creating a component, but there are serveral lifecycle methods & specs we can use that are mighty helpful when you actually want your component to do anything.
8889

89-
Lifecycle Methods:
90+
#### Lifecycle Methods:
9091

9192
* `componentWillMount` - Invoked once, on both client & server before rendering occurs.
9293

@@ -96,19 +97,19 @@ Lifecycle Methods:
9697

9798
* `componentWillUnmount` - invoked prior to unmounting component.
9899

99-
Specs:
100+
#### Specs:
100101

101102
* `getInitialState` - Return value is the initial value for state.
102103

103104
* `getDefaultProps` - Sets fallback props values if props are not supplied.
104105

105106
* `mixins` - An array of objects, used to extend the current component’s functionality.
106107

107-
State
108+
#### State
108109

109110
The state object is internal to a component. It holds data which can change over time.
110111

111-
```
112+
```javascript
112113
var Photo = React.createClass({
113114
getInitialState: function() {
114115
return {liked: false};
@@ -155,11 +156,11 @@ Here’s what happens when the component is rendered to the browser DOM:
155156

156157
* React isolates what has changed and updates the browser DOM.
157158

158-
#### Composition
159+
### Composition
159160

160161
Composition means combining smaller components to form a larger whole. For example the Photo component could be used inside a PhotoGallery component.
161162

162-
```
163+
```javascript
163164
var Photo = React.createClass({
164165
toggleLiked: function() {
165166
this.setState({liked: !this.state.liked});
@@ -218,11 +219,11 @@ There’s a new PhotoGallery component which generates Photo components. In this
218219

219220
The data is looped over and will generates 2 Photo components which are inserted into the return value of the component’s render function.
220221

221-
#### Events
222+
### Events
222223

223224
React also has a built in cross browser events system. The events are attached as properties of components and can trigger methods. Lets make our count increment below using events:
224225

225-
```
226+
```javascript
226227
var Counter = React.createClass({
227228
incrementCount: function() {
228229
this.setSate({count: this.state.count + 1});

0 commit comments

Comments
 (0)