Skip to content

Commit 527de8e

Browse files
remove react import, added react native snippet and fix a bug with reducer snippet
1 parent e4a89b8 commit 527de8e

File tree

5 files changed

+108
-117
lines changed

5 files changed

+108
-117
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
node_modules
1+
node_modules
2+
test

README.md

Lines changed: 34 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ This extension contains a selections of the best ReactJS Snippets chosen by Pedr
2424
| ------- | -------------------------------- |
2525
| `sty →` | Creates a Styled Components File |
2626
| `sdiv` | Creates a new Styled Div |
27+
| `stynative →` | Creates a Styled Components File (React Native) |
28+
| `sview` | Creates a new Styled View (React Native) |
2729

2830
## Redux - Thunk
2931

@@ -45,15 +47,9 @@ This extension contains a selections of the best ReactJS Snippets chosen by Pedr
4547
- `rfc` - Create **R**eact **F**unctional **C**omponent
4648

4749
```javascript
48-
import React from 'react';
49-
5050
import { Container } from './styles';
5151

52-
interface |Props {
53-
myProps?: boolean;
54-
}
55-
56-
const |: React.FC<|Props> = () => {
52+
const |: React.FC = () => {
5753
return (
5854
<Container>
5955
<h1>Hello - |</h1>
@@ -67,15 +63,11 @@ export default |;
6763
- `rfcall` - Create **R**eact **F**unctional **C**omponent with useCallback, useEffect and useState
6864

6965
```javascript
70-
import React, { useCallback, useEffect, useState } from 'react';
66+
import { useCallback, useEffect, useState } from 'react';
7167

7268
import { Container } from './styles';
7369

74-
interface |Props {
75-
myProps?: boolean;
76-
}
77-
78-
const |: React.FC<|Props> = () => {
70+
const |: React.FC = () => {
7971
const [myState, setMyState] = useState('');
8072

8173
useEffect(() => {
@@ -99,15 +91,11 @@ export default |;
9991
- `rfceffect` - Create **R**eact **F**unctional **C**omponent with use**Effect**
10092

10193
```javascript
102-
import React, { useEffect } from 'react';
94+
import { useEffect } from 'react';
10395

10496
import { Container } from './styles';
10597

106-
interface |Props {
107-
myProps?: boolean;
108-
}
109-
110-
const |: React.FC<|Props> = () => {
98+
const |: React.FC = () => {
11199
useEffect(() => {
112100
console.log('myEffect');
113101
}, []);
@@ -124,15 +112,11 @@ export default |;
124112
- `rfcstate` - Create **R**eact **F**unctional **C**omponent with use**State**
125113

126114
```javascript
127-
import React, { useState } from 'react';
115+
import { useState } from 'react';
128116

129117
import { Container } from './styles';
130118

131-
interface |Props {
132-
myProps?: boolean;
133-
}
134-
135-
const |: React.FC<|Props> = () => {
119+
const |: React.FC = () => {
136120
const [myState, setMyState] = useState('');
137121

138122
return (
@@ -192,21 +176,26 @@ const [|, set|] = useState();
192176
```javascript
193177
import styled from 'styled-components';
194178

195-
interface ContainerProps {
196-
myProps?: boolean;
197-
};
198-
199-
export const Container = styled.div<ContainerProps>`
200-
flex: 1;
201-
`;
179+
export const Container = styled.div``;
202180
```
203181

204182
- `sdiv` - Creates a new **S**tyled **div**
205183

206184
```javascript
207-
export const | = styled.div`
208-
flex: 1;
209-
`;
185+
export const | = styled.div``;
186+
```
187+
- `stynative` - Creates a **Sty**led Components File for React **Native**
188+
189+
```javascript
190+
import styled from 'styled-components/native';
191+
192+
export const Container = styled.View``;
193+
```
194+
195+
- `sview` - Creates a new **S**tyled **View**
196+
197+
```javascript
198+
export const | = styled.View``;
210199
```
211200

212201
### Redux - Thunk
@@ -229,25 +218,25 @@ export interface State {
229218
readonly data: [] | null;
230219
}
231220

232-
interface START_FETCH {
221+
interface StartFetch {
233222
type: typeof START_FETCH;
234223
kind: string;
235224
}
236225

237-
interface DONE_FETCH {
226+
interface DoneFetch {
238227
type: typeof DONE_FETCH;
239228
kind: string;
240229
}
241230

242-
interface GET_DATA {
231+
interface GetData {
243232
type: typeof GET_DATA;
244233
data: [];
245234
}
246235

247236
export type ActionTypes =
248-
| START_FETCH
249-
| DONE_FETCH
250-
| GET_DATA;
237+
| StartFetch
238+
| DoneFetch
239+
| GetData;
251240
```
252241

253242
- `rxreducer` - Creates a **R**edu**x** **Reducer** File
@@ -264,7 +253,7 @@ const INITIAL_STATE = {
264253

265254
export default (
266255
state = INITIAL_STATE,
267-
action = Types.ActionTypes,
256+
action: Types.ActionTypes,
268257
): Types.State => {
269258
switch (action.type) {
270259
case Types.START_FETCH:
@@ -287,18 +276,17 @@ import { ThunkAction } from 'redux-thunk';
287276
import { StoreState } from 'store';
288277
import * as Types from './types';
289278

290-
export const = (): ThunkAction<
279+
export const | = (): ThunkAction<
291280
void,
292281
StoreState,
293282
unknown,
294283
Action<string>
295-
> => async (dispatch) => {
284+
> => async dispatch => {
296285
try {
297286
dispatch({ type: Types.START_FETCH });
287+
dispatch({ type: Types.DONE_FETCH });
298288
} catch {
299289
// error
300-
} finally {
301-
dispatch({ type: Types.DONE_FETCH });
302290
}
303291
};
304292
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "pedros-choice-vscode-reactjs-snippets",
33
"displayName": "Pedro's Choice - ReactJS Snippets",
44
"description": "Pedro's choice of ReactJS snippets for development with VS Code",
5-
"version": "1.0.1",
5+
"version": "1.0.3",
66
"publisher": "pedroschoice",
77
"repository": {
88
"type": "git",

0 commit comments

Comments
 (0)