Skip to content

Instantly share code, notes, and snippets.

@MelodicCrypter
Last active April 15, 2021 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MelodicCrypter/cc488590efc1b15c5b3559c3ab58076d to your computer and use it in GitHub Desktop.
Save MelodicCrypter/cc488590efc1b15c5b3559c3ab58076d to your computer and use it in GitHub Desktop.
Webstorm Live Templates
// Code: edf
// Desc: For export components using index
export { default } from '.$END$';
// Code: rfc
// Desc: Functional Component Expression
import React from 'react';
const $Component$ = () => {
return (
<div>
<p>test$END$</p>
</div>
);
}
export default $Component$;
// Code: rnx
// Desc: Basic RN Functional Component
import React, { useState, useEffect } from 'react'
import { Text, StyleSheet, View } from 'react-native'
export default function $Component$() {
return (
<View style={styles.mainWrap}>
<Text> $Component$ screen </Text>
</View>
)
}
// Styles for this $Component$
const styles = StyleSheet.create({
mainWrap: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
})
$END$
// Code: rnxt
// Desc: RN Functional Component with Typescript
import React, { useState, useEffect } from 'react'
import { Text, StyleSheet, View } from 'react-native'
interface Props {
test?: string;
}
export default function $Component$({ test }: Props) {
return (
<View>
<Text> $Component$ view </Text>
</View>
)
}
// Styles for this $Component$
const styles = StyleSheet.create({
mainWrap: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
})
$END$
// Code: rfet
// Desc: Funtional Component Expression with TypeScript minimal
import React from 'react';
// interface Props {}
const $Component$ = (): React.ReactElement => {
return (
<div>
<p>test$END$</p>
</div>
);
}
export default $Component$;
// Code: rfet+
// Desc: Funtional Component Expression with TS and interface defaults
import React, { FC, ReactNode } from 'react';
interface Props {
children?: ReactNode;
title?: string;
on?: boolean;
size?: number;
getName?: () => {};
}
const $Component$ = ({ children, title, on, size, getName }: Props): React.ReactElement => {
return (
<div>
<p>test$END$</p>
</div>
);
}
export default $Component$;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment