Snippets for React/React Native/Redux with JavaScript and TypeScript lovers
https://marketplace.visualstudio.com/items?itemName=vadymbiliuk.ts-react-snippets
.js/.jsx
.ts/.tsx
cmd + shift + p
ctrl + shift + p
Please remember that examples below created for TypeScript. They are same for JavaScript in .js/.jsx files but without TypeScript features like interface etc.
import React from "react";import PropTypes from "prop-types";import React, { Component } from "react";
export interface IFileName {}
export interface IFileName {}
class FileName extends Component<IFileName, IFileName> {
  state = {};
  render() {
    return <div />;
  }
}
export { FileName };import React, { Component } from "react";
export interface IFileName {}
class FileName extends Component<IFileName> {
  render() {
    return <div />;
  }
}
export { FileName };import React from "react";
export interface IFileName {}
const FileName: React.FC<IFileName> = ({}) => {
  return <div />;
};
export { FileName };import { ModuleName } from "react-native";import React, { Component } from "react";
import { View } from "react-native";
export interface IFileName {}
export interface IFileName {}
class FileName extends Component<IFileName, IFileName> {
  state = {};
  render() {
    return <View />;
  }
}
export { FileName };import React, { Component } from "react";
import { View } from "react-native";
export interface IFileName {}
class FileName extends Component<IFileName> {
  render() {
    return <View />;
  }
}
export { FileName };import React from "react";
import { View } from "react-native";
export interface IFileName {}
export const FileName: React.FC<IFileName> = ({}) => {
  return <View />;
};
export { FileName };const [state, setstate] = useState(defaultState);useEffect(() => {}, []);const value = useContext(MyContext);const [state, dispatch] = useReducer(reducer, initialState);const memoizedCallback = useCallback(() => {}, []);const memoizedValue = useMemo(() => {}, []);const refContainer = useRef(initialValue);useImperativeHandle(initialValue, () => {}, []);useLayoutEffect(() => {}, []);useDebugValue(value);import { connect } from "react-redux";
import { ViewName } from "ViewPath";
const mapStateToProps = state => ({});
const mapDispatchToProps = {};
export default connect(mapStateToProps, mapDispatchToProps)(ViewName);import { configureStore, getDefaultMiddleware } from "@reduxjs/toolkit";
const preloadedState = {};
const middleware = [...getDefaultMiddleware()];
export const store = configureStore({
  preloadedState,
  reducer,
  middleware,
  devTools: process.env.NODE_ENV !== "production"
});import { createReducer } from "@reduxjs/toolkit";
const INITIAL_STATE = {};
const middleware = [...getDefaultMiddleware()];
export const FileName = createReducer(INITIAL_STATE, {
  [ActionType]: (state, action) => {}
});import { createAction } from "@reduxjs/toolkit";
export const ActionName = createAction(ActionType);import { createSlice } from "@reduxjs/toolkit";
const INITIAL_STATE = {};
export const FileName = createSlice({
  name: "FileName",
  initialState: INITIAL_STATE,
  reducers: {
    [ActionType]: (state, action) => {}
  }
});const selectedData = useSelector(state => state.YourObject);const dispatch = useDispatch();const store = useStore();Please remember that all native TypeScript snippets are included in .tsx files too
export interface IInterfaceName {}export type TypeName = type;export function funcName(): funcReturnType {}export const funcName = (): funcReturnType => {};export class className {
  // Fields:
  private readonly _fieldName: fieldType;
  // Properties:
  public fieldName: fieldType = propertyValue;
  constructor() {
    this._fieldName = this.fieldName;
  }
}export abstract class className {
  // Properties:
  public propertyName: propertyType = propertyValue;
}private readonly _fieldName: fieldType;public propertyName: propertyType = propertyValue;Pull requests are always welcome in develop branch. For major changes, please open an issue first to discuss what you would like to change.