Skip to content

Instantly share code, notes, and snippets.

View package.json の dependencies と devDependencies の使い分け.md
View App.js
import React from 'react';
import { Root } from 'native-base';
import * as Expo from 'expo';
import { AppNavigator } from './routes';
export default class App extends React.Component {
constructor() {
super();
View gen_rsa_key.go
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"io"
"log"
"os"
View app_error.go
package app_error
import (
"net/http"
"time"
"github.com/labstack/echo"
)
type ApiError struct {
View pull-to-refresh.css
/* taken from https://github.com/bryaneaton13/react-pull-to-refresh/blob/master/examples/basic/app.css */
.ptr-element {
position: absolute;
top: 0;
left: 0;
width: 100%;
color: #aaa;
z-index: 10;
text-align: center;
height: 50px;
@mori-dev
mori-dev / ミドルウェア.js
Created Jun 13, 2017
ブログ記事「React.js/redux アプリでの Google Analytics のイベントトラッキングの設定」の補足コード
View ミドルウェア.js
import { createMiddleware } from 'redux-beacon';
import { logger } from 'redux-beacon/extensions/logger';
import { GoogleAnalytics } from 'redux-beacon/targets/google-analytics';
// Redux Beacon EventDefinition
// イベントトラッキング: https://developers.google.com/analytics/devguides/collection/analyticsjs/events?hl=ja
export const GAEvents = {
C1_A1_L1: {
eventFields: (action: any) => ({
hitType: 'event',
@mori-dev
mori-dev / src__index.browser.js
Last active Oct 1, 2019
redux-persist でブラウザストレージに一部のデータを保存しつつ、ストアに復旧するまで render を防ぐには
View src__index.browser.js
class MyAppProvider extends Component {
constructor() {
super()
this.state = { rehydratedFlag: false }
}
componentWillMount() {
appEventHandler.on(AppEvents.FINISH_REHYDRATE_STORE, () => {
this.setState({ rehydratedFlag: true });
@mori-dev
mori-dev / payjp_checkout.js
Last active Nov 11, 2019
PAY.JP の Checkout 用の React.js コンポーネント
View payjp_checkout.js
// @flow
import React, { Component } from 'react';
import { findDOMNode } from 'react-dom';
class PayjpCheckout extends Component {
constructor(props: Object) {
super(props);
this.windowAlertBackUp = window.alert;
this.script = document.createElement('script');
@mori-dev
mori-dev / sample_saga_test.js
Last active Apr 14, 2017
redux アプリで定期実行処理を書くには / saga のテスト
View sample_saga_test.js
import assert from 'power-assert';
import { createMockTask } from 'redux-saga/lib/utils';
import { take, fork, cancel, put, call } from 'redux-saga/effects';
import { delay } from 'redux-saga';
import * as actions from '../../../src/actions/periodic_inspections/some_check';
import * as ActionTypes from '../../../src/actions/action_types';
import {
watchSampleTrigger,
worker,
intervalMs
@mori-dev
mori-dev / sample_middleware.js
Created Apr 14, 2017
redux アプリで定期実行処理を書くには / ミドルウェア
View sample_middleware.js
function businessLogic(store: any): {stopFlag: boolean} {
// なんらかのビジネスロジックを記述
// ミドルウェアでは次のようにステートを取り出せます。
// const stateName = store.getState().stateName;
return { stopFlag: false };
}
export default (store: any) => (next: any) => (action: any) => {
if (action.type === ActionTypes.CHECK_SAMPLE_EXEC) {
if (businessLogic(store).stopFlag) {
You can’t perform that action at this time.