How to add Live Template in Webstorm
- open preferences
- editor> live templates
- add template group for React Native
- add templates below to the new group
- define context > javascript
- edit variables > add "fileNameWithoutExtension" to "$fnName$"
debugger;
console.log($CONTENT$);
(function () {
$CONTENT$
}());
#### `pro`: Promise ES6 style
```javascript
new Promise((resolve, reject) => {
$CONTENT$
});
new Promise(function(resolve, reject) {
$CONTENT$
});
($ARGUMENTS$) => {
$BODY$
}
function $NAME$($ARGUMENTS$) {
$BODY$
}
class $CLASS_NAME$ {
constructor($CONSTRUCTOR_ARGUMENTS$) {
$CONTRUCTOR_BLOCK$
}
}
'use strict';
$END$
import React, { Component } from 'react';
import { View } from 'react-native';
class $fnName$ extends Component {
propTypes = {$PROP_TYPES$}
state = {$STATE$};
render() {
return (
$RENDER$
)
}
}
import React from 'react';
import { View } from 'react-native';
export const $fnName$ = () => {
return (
$RENDER$
)
};
$fnName$.propTypes = {
$PROP_TYPES$
}
export function dummieDispatch (state) {
return {
type: TEST,
state,
}
}
export function dummieAction () {
return function (dispatch, getState) {
dispatch(dummieDispatch())
}
}
const initialState = {
}
export default function settings (state = initialState, action) {
switch (action.type) {
case TEST :
return {
...state,
}
default :
return state
}
}
import { StyleSheet } from 'react-native';
const styles = StyleSheet.create({
$CONTENT$
});
export default styles;
capitalize(camelCase(fileNameWithoutExtension()));()
i thin this expression more better, because
news-header.jsx
->NewsHeader