Skip to content

Commit 588c565

Browse files
sveinpgmarkerikson
authored andcommitted
Changed highlight theme and updated snippet language (#1035)
* Changed highlight theme and updated snippet language * Try switching theme to Monokai
1 parent 289ef99 commit 588c565

File tree

5 files changed

+30
-28
lines changed

5 files changed

+30
-28
lines changed

docs/GettingStarted.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ npm install --save react-redux
1919

2020
or
2121

22-
```
22+
```bash
2323
yarn add react-redux
2424
```
2525

@@ -64,7 +64,7 @@ Correspondingly, the `connect` function takes two arguments, both optional:
6464

6565
Normally, you’ll call `connect` in this way:
6666

67-
```jsx
67+
```js
6868
const mapStateToProps = (state, ownProps) => ({
6969
// ... computed data from state and optionally ownProps
7070
});
@@ -185,7 +185,7 @@ Let’s work on `<AddTodo />` first. It needs to trigger changes to the `store`
185185

186186
Our `addTodo` action creator looks like this:
187187

188-
```JavaScript
188+
```js
189189
// redux/actions.js
190190
import { ADD_TODO } from './actionTypes';
191191

@@ -203,7 +203,7 @@ export const addTodo = content => ({
203203

204204
By passing it to `connect`, our component receives it as a prop, and it will automatically dispatch the action when it’s called.
205205

206-
```jsx
206+
```js
207207
// components/AddTodo.js
208208

209209
// ... other imports
@@ -277,7 +277,7 @@ The `<TodoList />` component is responsible for rendering the list of todos. The
277277

278278
Our `<Todo />` component takes the todo item as props. We have this information from the `byIds` field of the `todos`. However, we also need the information from the `allIds` field of the store indicating which todos and in what order they should be rendered. Our `mapStateToProps` function may look like this:
279279

280-
```jsx
280+
```js
281281
// components/TodoList.js
282282

283283
// ...other imports
@@ -299,7 +299,7 @@ export default connect(mapStateToProps)(TodoList);
299299

300300
Luckily we have a selector that does exactly this. We may simply import the selector and use it here.
301301

302-
```jsx
302+
```js
303303
// redux/selectors.js
304304

305305
export const getTodosState = store => store.todos;
@@ -318,7 +318,7 @@ export const getTodos = store =>
318318
getTodoList(store).map(id => getTodoById(store, id));
319319
```
320320

321-
```jsx
321+
```js
322322
// components/TodoList.js
323323

324324
// ...other imports
@@ -354,7 +354,7 @@ If you call `connect` without providing any arguments, your component will:
354354
- _not_ re-render when the store changes
355355
- receive `props.dispatch` that you may use to manually dispatch action
356356

357-
```jsx
357+
```js
358358
// ... Component
359359
export default connect()(Component); // Component will receive `dispatch` (just like our <TodoList />!)
360360
```
@@ -366,7 +366,7 @@ If you call `connect` with only `mapStateToProps`, your component will:
366366
- subscribe to the values that `mapStateToProps` extracts from the store, and re-render only when those values have changed
367367
- receive `props.dispatch` that you may use to manually dispatch action
368368

369-
```jsx
369+
```js
370370
// ... Component
371371
const mapStateToProps = state => state.partOfState;
372372
export default connect(mapStateToProps)(Component);
@@ -379,7 +379,7 @@ If you call `connect` with only `mapDispatchToProps`, your component will:
379379
- _not_ re-render when the store changes
380380
- receive each of the action creators you inject with `mapDispatchToProps` as props and automatically dispatch the actions upon being called
381381

382-
```jsx
382+
```js
383383
import { addTodo } from "./actionCreators";
384384
// ... Component
385385
export default connect(
@@ -395,7 +395,7 @@ If you call `connect` with both `mapStateToProps` and `mapDispatchToProps`, your
395395
- subscribe to the values that `mapStateToProps` extracts from the store, and re-render only when those values have changed
396396
- receive all of the action creators you inject with `mapDispatchToProps` as props and automatically dispatch the actions upon being called.
397397

398-
```jsx
398+
```js
399399
import * as actionCreators from "./actionCreators";
400400
// ... Component
401401
const mapStateToProps = state => state.partOfState;
@@ -415,7 +415,7 @@ Now let’s connect the rest of our `<TodoApp />`.
415415

416416
How should we implement the interaction of toggling todos? A keen reader might already have an answer. If you have your environment set up and have followed through up until this point, now is a good time to leave it aside and implement the feature by yourself. There would be no surprise that we connect our `<Todo />` to dispatch `toggleTodo` in a similar way:
417417

418-
```jsx
418+
```js
419419
// components/Todo.js
420420

421421
// ... other imports
@@ -438,7 +438,7 @@ Finally, let’s implement our `VisibilityFilters` feature.
438438

439439
The `<VisibilityFilters />` component needs to be able to read from the store which filter is currently active, and dispatch actions to the store. Therefore, we need to pass both a `mapStateToProps` and `mapDispatchToProps`. The `mapStateToProps` here can be a simple accessor of the `visibilityFilter` state. And the `mapDispatchToProps` will contain the `setFilter` action creator.
440440

441-
```jsx
441+
```js
442442
// components/VisibilityFilters.js
443443

444444
// ... other imports
@@ -479,7 +479,7 @@ export const getTodosByVisibilityFilter = (store, visibilityFilter) => {
479479

480480
And connecting to the store with the help of the selector:
481481

482-
```jsx
482+
```js
483483
// components/TodoList.js
484484

485485
// ...

docs/api.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ If you *really* need to, you can manually pass `store` as a prop to every `conne
2323

2424
#### Vanilla React
2525

26-
```js
26+
```jsx
2727
ReactDOM.render(
2828
<Provider store={store}>
2929
<MyRootComponent />
@@ -34,7 +34,7 @@ ReactDOM.render(
3434

3535
#### React Router
3636

37-
```js
37+
```jsx
3838
ReactDOM.render(
3939
<Provider store={store}>
4040
<Router history={history}>
@@ -92,32 +92,33 @@ It does not modify the component class passed to it; instead, it *returns* a new
9292
#### The arity of mapStateToProps and mapDispatchToProps determines whether they receive ownProps
9393

9494
> Note: `ownProps` **is not passed** to `mapStateToProps` and `mapDispatchToProps` if the formal definition of the function contains one mandatory parameter (function has length 1). For example, functions defined like below won't receive `ownProps` as the second argument.
95-
```javascript
95+
96+
```js
9697
function mapStateToProps(state) {
9798
console.log(state); // state
9899
console.log(arguments[1]); // undefined
99100
}
100101
```
101-
```javascript
102+
```js
102103
const mapStateToProps = (state, ownProps = {}) => {
103104
console.log(state); // state
104105
console.log(ownProps); // undefined
105106
}
106107
```
107108
Functions with no mandatory parameters or two parameters **will receive** `ownProps`.
108-
```javascript
109+
```js
109110
const mapStateToProps = (state, ownProps) => {
110111
console.log(state); // state
111112
console.log(ownProps); // ownProps
112113
}
113114
```
114-
```javascript
115+
```js
115116
function mapStateToProps() {
116117
console.log(arguments[0]); // state
117118
console.log(arguments[1]); // ownProps
118119
}
119120
```
120-
```javascript
121+
```js
121122
const mapStateToProps = (...args) => {
122123
console.log(args[0]); // state
123124
console.log(args[1]); // ownProps
@@ -368,7 +369,7 @@ export default connect(mapStateToPropsFactory, mapDispatchToPropsFactory)(TodoAp
368369

369370
## connectAdvanced
370371

371-
```
372+
```js
372373
connectAdvanced(selectorFactory, [connectOptions])
373374
```
374375

@@ -426,6 +427,7 @@ Returns the wrapped component instance. Only available if you pass `{ withRef: t
426427
#### Examples
427428

428429
#### Inject `todos` of a specific user depending on props, and inject `props.userId` into the action
430+
429431
```js
430432
import * as actionCreators from './actionCreators'
431433
import { bindActionCreators } from 'redux'
@@ -448,7 +450,7 @@ export default connectAdvanced(selectorFactory)(TodoApp)
448450

449451
## createProvider
450452

451-
```
453+
```js
452454
createProvider([storeKey])
453455
```
454456

docs/api/Provider.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ In the example below, the `<App />` component is our root-level component. This
3131

3232
**Vanilla React Example**
3333

34-
```js
34+
```jsx
3535
import React from 'react';
3636
import ReactDOM from 'react-dom';
3737
import { Provider } from 'react-redux';
@@ -52,7 +52,7 @@ In the example below, the `<App />` component is our root-level component. This
5252

5353
**Usage with React Router**
5454

55-
```js
55+
```jsx
5656
import React from 'react';
5757
import ReactDOM from 'react-dom';
5858
import { Provider } from 'react-redux';

docs/troubleshooting.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ If you’re using React Router 0.13, you might [bump into this problem](https://
2828

2929
Root view:
3030

31-
```js
31+
```jsx
3232
Router.run(routes, Router.HistoryLocation, (Handler, routerState) => { // note "routerState" here
3333
ReactDOM.render(
3434
<Provider store={store}>
@@ -62,7 +62,7 @@ The _best_ solution to this is to make sure that your components are pure and pa
6262

6363
If that’s not practical for whatever reason (for example, if you’re using a library that depends heavily on React context), you may pass the `pure: false` option to `connect()`:
6464

65-
```
65+
```js
6666
function mapStateToProps(state) {
6767
return { todos: state.todos }
6868
}

website/siteConfig.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const siteConfig = {
6161

6262
highlight: {
6363
// Highlight.js theme to use for syntax highlighting in code blocks.
64-
theme: "default"
64+
theme: "monokai"
6565
},
6666

6767
// Add custom scripts here that would be placed in <script> tags.

0 commit comments

Comments
 (0)