<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
import React, { useContext } from 'react';
npm i -S tslint tslint-config-airbnb tslint-config-prettier tslint-react prettier
{
"extends": ["tslint:recommended", "tslint-config-prettier", "tslint-config-airbnb", "tslint-react"],
/* ... */
}
console.log({ ...obj });
console.log(JSON.stringify(obj));
console.log(JSON.stringify(obj, null, ' ')); // красивый вывод с отступами
import * as React from 'react';
import { connect, DispatchProp } from 'react-redux';
import { connectedPropSelector } from './selectors';
interface OwnProps {
ownProp: string,
}
interface ConnectedProps {
connectedProp: string,
}
type Props = OwnProps & ConnectedProps & DispatchProp<any>;
interface State {
someKey: string,
}
class Example extends React.Component<Props, State> {
state = {
someKey: 'someValue',
};
render() {
const { ownProp, connectedProp } = this.props;
return ( /* ... */ );
}
}
const mapStateToProps = state => ({
connectedProp: connectedPropSelector(state),
});
export default connect(mapStateToProps)(Example);
public onRoute = () => {
if (data.role_type === `/${document.location.pathname.split('/')[1]}`) {
return <Component/>; // тут ничего не передается
}
return this.context.router.history.push('/404');
}
public onRoute = () => {
if (data.role_type === `/${document.location.pathname.split('/')[1]}`) {
return <Component {...this.props} />;
}
return this.context.router.history.push('/404');
}
<AuthRoute path='/some_path' component={SomeComponent} />
declare module 'koa-connect-flash' {
const def: any;
export default def;
}