Igor Suvorov
Программист-предприниматель
15 Nov 2016
2013
var HelloComponent = React.createClass({
render: function render() {
return React.createElement(
"div", null,
"Hello ",
this.props.name
);
}
});
React.render(
React.createElement(
HelloComponent,
{ name: "Igor" }
),
document.body
);
var HelloComponent = React.createClass({
render: function() {
return <div>
Hello {this.props.name}
</div>;
}
});
React.render(
<HelloComponent name="Igor" />,
document.body
);
function FieldGroup({ id, label, help, ...props }) {
return (
<FormGroup controlId={id}>
<ControlLabel>{label}</ControlLabel>
<FormControl {...props} />
{help && <HelpBlock>{help}</HelpBlock>}
</FormGroup>
);
}
const formInstance = (
<form>
<FieldGroup
id="formControlsEmail"
type="email"
label="Email address"
placeholder="Enter email"
/>
<FieldGroup
id="formControlsPassword"
label="Password"
type="password"
/>
</form>
);
// @flow
function bar(x: string): number {
return x.length;
}
bar('Hello, world!');
import { Button } from 'react-bootstrap';
import './style.css';
function render(params) {
const view = require("./buttons.jade");
...
return html;
}
if (__DEV__) {
console.log('LOG');
connectToSSH('#password')
}
import Hello from '~/components/Hello';
class WebpackConfig {
getConfig() {}
}
class WebpackClientConfig extends WebpackConfig {
}
class WebpackServerConfig extends WebpackConfig {
}
getPreConfig() {
return {
context: this.resolvePath('src'),
target: this.getTarget(),
entry: this.getEntry(),
resolve: this.getResolve(),
output: this.getOutput(),
module: this.getModule(),
plugins: this.getPlugins(),
cache: this.isDebug(),
debug: this.isDebug(),
stats: this.getStats(),
postcss: (...args) => this.getPostcssModule(...args),
}
}
getLoaders() {
return [
this.getJsxLoader(),
...this.getCssLoaders(),
{
test: /\.json$/,
loader: 'json-loader',
},
{
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2)(\?.+)?$/,
loader: 'url-loader',
query: {
name: this.isDebug() ? '[path][name].[ext]?[hash]' : '[hash].[ext]',
limit: 10000,
},
},
{
test: /\.(eot|ttf|wav|mp3)(\?.+)?$/,
loader: 'file-loader',
query: {
name: this.isDebug() ? '[path][name].[ext]?[hash]' : '[hash].[ext]',
},
},
]
}
{
test: /\.global\.css$/,
loaders: [
'isomorphic-style-loader',
`css-loader?${JSON.stringify({
sourceMap: this.isDebug(),
modules: false,
minimize: !this.isDebug(),
})}`,
],
},
{
test: /\.css$/,
exclude: /(global.css)/,
loaders: [
'isomorphic-style-loader',
`css-loader?${JSON.stringify({
sourceMap: this.isDebug(),
modules: true,
localIdentName: this.isDebug() ? '[name]_[local]_[hash:base64:3]' : '[hash:base64:4]',
minimize: !this.isDebug(),
})}`,
'postcss-loader?pack=default',
],
},
getGlobals() {
return {
'process.env.NODE_ENV': JSON.stringify(this.getEnv()),
__ENV__: JSON.stringify(this.getEnv()),
__DEV__: this.getEnv() === 'development',
__PROD__: this.getEnv() === 'production',
}
}
getTarget() {
return 'web'
}
getEntry() {
return './client.js'
}
getGlobals() {
return {
...super.getGlobals(),
__SERVER__: false,
__CLIENT__: true,
__BROWSER__: true,
}
}
Transforming styles with JS plugins
SASS vs LESS vs Stylus vs PostCSS
PostCSS vs PreCSS vs SugarCSS vs ...
Global vs Modules
CSS Modules vs Inline
HTML Inline vs JSS vs Radium
JS vs TS vs ..
ES5 vs ES6 vs ES7 ...
Babel Stage 0 vs ... vs Stage 4
Babel plugins: JSX vs Decorators ...
статьте лайки, подписывайтесь на канал
telegram.me/isuvorov
vk.com/igor.suvorov
github.com/isuvorov
By Igor Suvorov
* Как работает React? что такое Virtual DOM? * Концепция Компонентов. * Популярные пакеты под React. * Сборщик Webpack. * PostCSS, Модульный CSS, React CSS Modules. * Визуальное тестирование компонентов с помощью Storybook.