update react snippets

This commit is contained in:
Ray Elliott 2020-04-25 21:55:30 +01:00
parent 058cd4214c
commit 53b0720cd1
1 changed files with 64 additions and 26 deletions

View File

@ -4,7 +4,7 @@ endsnippet
snippet if "if ( ... ) { ... }" snippet if "if ( ... ) { ... }"
if ($1) { if ($1) {
$0 $0
} }
endsnippet endsnippet
@ -18,21 +18,21 @@ endsnippet
snippet if "if ( ... ) { ... }" snippet if "if ( ... ) { ... }"
if ($1) { if ($1) {
$0 $0
} }
endsnippet endsnippet
snippet ifelse "if ( ... ) { ... } else { ... }" snippet ifelse "if ( ... ) { ... } else { ... }"
if ($1) { if ($1) {
$2 $2
} else { } else {
$0 $0
} }
endsnippet endsnippet
snippet for "for ( ... ) { ... }" snippet for "for ( ... ) { ... }"
for (let ${1:index} = ${2:0}; $1 $3; $1${4:++}) { for (let ${1:index} = ${2:0}; $1 $3; $1${4:++}) {
$0 $0
} }
endsnippet endsnippet
@ -42,36 +42,74 @@ setTimeout(() => {$0
endsnippet endsnippet
snippet jsx "import React ..." snippet jsx "import React ..."
import React from "react" import React from "react";
class $1 extends React.Component {
constructor(props) {
super(props);
this.state = {
}
}
render() {
return (
<${2:div} className={this.props.className}>
$0
</$2>
);
}
}
export default () => ( export default () => (
<${1:div}>$0</$1> <S.$1}></S.$1>
) );
endsnippet endsnippet
snippet jsxs "import React ... (styled)" snippet jsxs "import React ... styled"
import React from "react" import React from "react";
import styled from "styled-components" import styled from "styled-components";
const $1 = styled.${2:div}\` const S = {};
$3
\` class $1 extends React.Component {
constructor(props) {
super(props);
this.state = {
}
}
render() {
return (
<${2:div} className={this.props.className}>
$0
</$2>
);
}
}
S.$1 = styled($1)\`
\`;
export default () => ( export default () => (
<$1>$0</$1> <S.$1}></S.$1>
) );
endsnippet endsnippet
snippet xc "class ..." snippet jsc "class ... extends React.Component"
class $1 extends React.component { class $1 extends React.Component \{
constructor(props) { ${2: constructor(props) \{
super(props) super(props);
this.setState({$0}) this.state = \{
} \}
\}}
render() { render() \{
return ( return (
) <${3:div}${4: className=\{this.props.className\}}>
} $0
</$3>
);
}
} }
endsnippet endsnippet