const VK = window.VK;
/*eslint-disable */
VK.Api.call({
/* ... */
});
/*eslint-enable */
{
"extends": [
"airbnb",
"prettier",
"prettier/react"
],
"plugins": [
"prettier"
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"browser": true,
"node": true
},
"rules": {
"no-plusplus": 0,
"no-confusing-arrow": 0,
"no-restricted-syntax": 0,
"guard-for-in": 0,
"class-methods-use-this": 0,
"jsx-a11y/no-static-element-interactions": 0,
"jsx-a11y/anchor-is-valid": 0,
"react/no-danger": 0,
"react/prop-types": 0,
"react/jsx-filename-extension": 0,
"react/jsx-curly-brace-presence": ["error", { "props": "never", "children": "never" }],
"import/no-unresolved": ["error", { "commonjs": true }],
"import/extensions": 0,
"import/no-extraneous-dependencies": ["error", {"devDependencies": true}],
"import/prefer-default-export": 0,
"prettier/prettier": ["error", {
"singleQuote": true,
"trailingComma": "all"
}]
},
"settings" : {
"import/resolver": {
"webpack": {
"config": "webpack/base.config.js"
}
}
}
}
{
"assets-webpack-plugin": "^3.5.1",
"babel-eslint": "^8.2.1",
"eslint": "^4.18.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-prettier": "^2.9.0",
"eslint-import-resolver-webpack": "^0.8.4",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-prettier": "^2.6.0",
"eslint-plugin-react": "^7.6.1",
"prettier": "^1.10.2",
}
export const handleError = error => ({ type: 'NEW_ERROR', payload: error });
export const doSomething = data => ({ type: 'DO_SOMETHING', payload: data });
import { apiCall } from './api';
import { handleError, doSomething } from './actionCreators';
export const asyncAction = () => dispatch => {
try {
const result = await apiCall();
dispatch(doSomething(result));
return result;
} catch (e) {
dispatch(hanldeError(e));
}
};
export const handleError = error => ({ type: 'NEW_ERROR', payload: error });
export const doSomething = data => ({ type: 'DO_SOMETHING', payload: data });
import { connect } from 'react-redux';
import { apiCall } from './api';
import { handleError, doSomething } from './actionCreators';
class ExampleComponent extends React.Component {
componentDidMount() {
const { dispatch } = this.props;
apiCall().then(
res => dispatch(doSomething(res)),
err => dispatch(handleError(err)),
);
}
render() { /* ... */ }
}
export default connect()(ExampleComponent);
import { connect } from 'react-redux';
import { apiCall } from './api';
import { handleError, doSomething } from './actionCreators';
class ExampleComponent extends React.Component {
componentDidMount() {
const { doSomething, handleError } = this.props;
apiCall().then(
res => doSomething(res),
err => handleError(err),
);
}
render() { /* ... */ }
}
mapDispatchToProps = {
handleError,
doSomething,
};
export default connect(null, mapDispatchToProps)(ExampleComponent);
store.dispatch(someAction());
Error: Cannot find module 'glob'
cross-env NODE_ENV=production node server
.get('http://example.com/wp-content/themes/armed/mobile/react.php')
127.0.0.1 project
server {
listen 80;
server_name project;
location ^~ / {
proxy_pass http://localhost:3000/;
}
location ^~ /api/ {
proxy_pass http://localhost:3001/api/;
}
}
import React, { Component } from 'react';
import { Child } from './Child';
import { getSomeData } from './api';
class Parent extends Component {
state = {
data: [],
};
componentDidMount() {
getSomeData.then(data => this.setState({ data });
}
render() {
return <Child data={this.state.data} />;
}
}
import libraryName from 'libraryName';
libraryName.someMethod();
import { someMethod } from 'libraryName';
someMethod();
import React from 'react';
import styled from 'styled-components';
const SVG = styled.svg`
display: inline-block;
vertical-align: middle;
`;
const Icon = ({ name, ...props }) {
if (!name) {
throw new Error('Unknown icon name!');
}
return (
<SVG {...props}>
<use xlinkHref={`#icon-${name}`} />
</SVG>
);
}
export default Icon;
import React from 'react';
import styled from 'styled-components';
import { Icon } from './components';
const StyledIcon = styled(Icon)`
fill: ${props => props.state.fill};
`;
const Example = ({ iconState }) => <StyledSVG name="profile" state={iconState} />;
export default Example;
import React, { Component } from 'react';
import { withRouter } from 'react-router-dom';
class Example extends Component {
handler = () => {
this.props.history.push('/cources');
};
render() { /* ... */ }
}
export default withRouter(Example);
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
class Example extends Component {
render() {
return <Link to="/cources" />;
}
}
export default Example;
export const asyncAction = (...someArgs) => async dispatch => {
const res = await someAsyncCall(...someArgs);
dispatch({ type: SOME_ACTION_TYPE, payload: res });
return res;
};
componentDidMount() {
const { dispatch } = this.props;
dispatch(asyncAction(...optionalArgs)).then(result => doSomething(result));
}
componentDidMount() {
const { asyncAction } = this.props;
asyncAction(...optionalArgs).then(result => doSomething(result));
}
export const asyncAction = (...someArgs) => async dispatch => {
const res = await someAsyncCall(...someArgs);
dispatch({ type: SOME_ACTION_TYPE, payload: res });
};
componentDidMount() {
const { dispatch } = this.props;
dispatch(asyncAction(...optionalArgs)).then(() => doSomething());
}
const loading = () => ({ ... });
const success = () => ({ ... });
const error = (message) => ({ ... });
export const send = ({ name, phone }) => { ... };
export const send = ({ name, phone }) => { ... };
function loading() {
return { ... };
};
function success() {
return { ... };
};
function error(message) {
return { ... };
};