React Snippets
React Function StateLess
rf→
import React from "react";
import PropTypes from "prop-types";
const Component = (props) => {
return <div></div>;
};
Component.propTypes = {};
export { Component };
rfts→
import React from "react";
type Props = {};
const Component = (props: Props) => {
return <div></div>;
};
export { Component };
React Function
rfs→
import React, { useState } from "react";
import PropTypes from "prop-types";
const Component = (props) => {
const [state, setState] = useState(InitialState);
return <div></div>;
};
Component.propTypes = {};
export { Component };
rfsts→
import React from "react";
type Props = {};
const Component = (props: Props) => {
const [state, setState] = useState<Type>(InitialState);
return <div></div>;
};
export { Component };
useState
rs→
const [state, setState] = useState(InitialState);
rsts→
const [state, setState] = useState < Type > InitialState;
useReducer
rur→
const [state, dispatch] = useReducer(Reducer, InitialState, Init);
useMemo
rum→
const FunctionName = useMemo(FunctionImp, [UpdateParams]);
useEffect
rue→
useEffect(FunctionImp, [UpdateParams]);