Skip to content

Instantly share code, notes, and snippets.

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() {
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 = {
{
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',
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;
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;
const ButtonContainer = cssta(View)`
--primary: #e67e22;
--foreground: var(--primary);
--background: white;
...
border: 1px solid var(--primary);
background-color: var(--background);
[active] {
const ButtonContainer = cssta(Animated.View)`
...
transition: background-color 0.2s;
...
`;
const ButtonText = cssta(Animated.Text)`
...
transition: color 0.3s;
`;
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
const getAction = ({ action, state }) =>
typeof action === "function" ? action(state) : action
const Dispatch = connect(state => ({ state }))(
class Dispatch extends Component {
componentWillMount() {
const currentAction = getAction(this.props)
if (currentAction != null) this.props.dispatch(currentAction)
}
Rx.Observable.from(store)
.map(state => state.isPlaying)
.distinctUntilChanged()
.subscribe(isPlaying => {
if (isPlaying) {
play()
} else {
pause()
}
})