Skip to content

Instantly share code, notes, and snippets.

import { View, Text } from 'react-native';
import cssta from 'cssta/native';
const ButtonContainer = cssta(View)`
margin: 10px 50px;
padding: 10px 15px;
border-radius: 1000px;
border: 1px solid #e67e22;
background-color: white;
class TouchableCustom extends Component {
constructor() {
super();
this.state = { active: false };
this.onPressIn = () => this.setState({ active: true });
this.onPressOut = () => this.setState({ active: false });
}
render() {
const { active } = this.state;
{
module: {
loaders: [{
// This is specifically for Cssta
test: /\.jsx?$/,
loader: 'babel-loader',
options: {
plugins: [
['babel-plugin-cssta', { output: 'dist/styles.css' }],
'transform-es2015-modules-commonjs',
import { createComponent, Component } from 'react';
import { Dimensions } from 'react-native';
/*
Matches components based on screen min/max width/height queries. Uses component from the first size
descriptor that matches the screen.
Depends upon https://github.com/facebook/react-native/pull/9701
type Size = {
const plugin = (instance) => {
instance.extend('parseParenFreeIfStatement', () => function parseParenFreeIfStatement(node) {
this.next();
node.test = this.parseExpression();
node.consequent = this.parseBlock(false);
node.alternate = this.eat(tt._else) ? this.parseParenFreeElseStatement() : null;
return this.finishNode(node, 'IfStatement');
});
instance.extend('parseParenFreeElseStatement', () => function parseParenFreeElseStatement() {
const plugin = (instance) => {
instance.extend('parseIfStatement', inner => function (node) {
this.next();
const isParenFree = this.match(tokenTypes.parenL);
node.test = isParenFree
? this.parseExpression()
: this.parseParenExpression();
node.consequent = isParenFree
? this.parseBlock(false)
pp.parseStatement = function (declaration, topLevel) {
let node = this.startNode();
if (this.match(tokenTypes._if)) {
return this.parseIfStatement(node);
} else {
...
}
}
const { plugins } = require('babylon/lib/parser');
const pluginName = 'swift-blocks';
const plugin = createSwiftBlocksPlugin();
plugins[pluginName] = 'swift-blocks';
module.exports = () => ({
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push(pluginName);
},
export default function () {
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("jsx");
}
};
}
if condition {
doSomething();
}