Skip to content

Instantly share code, notes, and snippets.

View kenmori's full-sized avatar
🏠
Working from home

KenjiMorita kenmori

🏠
Working from home
View GitHub Profile
@kenmori
kenmori / index.js
Last active March 28, 2017 05:32
【Android/ (Chrome/56.0.2924.87)】how to fix 「Form submission canceled because the form is not connected」
//An error occurs //The form will be canceled. On Android/Chrome/56.0.2924.87
$("<form />", { action: "/hoge/fuga", method: "post" })
.append($("<input />", { type: "hidden", name: "xtoken", value: xtoken }))
.append($("<input />", { type: "hidden", name: "state", value: "/hoge/" + hogeId }))
.append($("<input />", { type: "hidden", name: "hoge", value: hoge }))
.append($("<input />", { type: "hidden", name: "back", value: location.pathname }))
.submit();
/////
//// add .appendTo(document.body), before .submit()
@kenmori
kenmori / Child-keys-must-be-unique.js
Last active February 10, 2017 12:43
keyを持つコードとkeyを持たないコード【React】これ。Warning: flattenChildren(...): Encountered two children with the same key, `keyName`. Child keys must be unique; when two children share a key, only the first child will be used.
////////no key////////keyを持たないで返しているコード///
const users = this.state.users.map(function (user){
return <User id={user.id} name={user.name} />;
});
////////add key//////keyを設定して返しているコード///
const users = this.state.users.map(function (user){
return <User id={user.id} key={user.id} name={user.name} />;
});
@kenmori
kenmori / gist:6c3cb9d5d6a15205a9a54a15e7fad37e
Last active February 15, 2017 12:00
flowtype/react. Required module not found
import React, { Component } from 'hogehogefolder/react';//error react. Required module not found
const MailToBtn = ({mailAddress, addClass, children }: Props) => (
<a className='block w100 ' href={mailAddress}>
<button className={`${addClass} appearanceNone outlineNone btnMain btnShadow1 size1 type1 btn100 pad0`} type='button'>
{children}
</button>
</a>
)
export default MailToBtn
[ignore]
.*/node_modules/.*
[include]
./resources/es6
[libs]//add flowtyed folder
./resources/decls
[options]
@kenmori
kenmori / enterns.js
Created February 15, 2017 12:08
add flowtyped js file to folder after set libs in .flowtype.config 【flowtype】これ。react. Required module not found
declare module 'hogehogefolder/react' {
declare module.exports: any;
}
@kenmori
kenmori / Required-module-not-found.txt
Created February 15, 2017 12:12
react. Required module not found
resources/es6/hogehoge/components/stateless/Button/MailToBtn.js:3
3: import React, { Component } from 'tel_fortune_lib/react';
^^^^^^^^^^^^^^^^^^^^^^^ hogehogefolder/react. Required module not found
@kenmori
kenmori / flowtype.js
Created February 18, 2017 11:19
【flowtype/React/Class】これ。how to fix 「Covariant property `[fn]` incompatible with contravariant use in ``` assignment of property `[fn]`」
////error
this._increment = this._increment.bind(this);
^^^^^^^^^^ property `_increment`. Covariant property `_increment` incompatible with contravariant use in
27: this._increment = this._increment.bind(this);
^^^^^^^^^^^^^^^ assignment of property `_increment`
/////// code ////////
constructor(props: Props){
super(props);
this.state = {
constructor(props: Props){
super(props);
this.state = {
value : this.props.value
}
const self: any = this
self._increment = this._increment.bind(this);
self._decrement = this._decrement.bind(this);
};
@kenmori
kenmori / all_flowtyped.js
Created February 18, 2017 11:31
Reactl_flowtyped_classSyntax_example.js
/* @flow */
//https://github.com/facebook/flow/issues/1517
import React, {Component} from 'react';
type Props = {
title: string,
visited: boolean,
value: number
}
@kenmori
kenmori / HigherOrderFunction.md
Created February 19, 2017 10:36
HigherOrderFunction

問327

下記のような減算する関数subtractと加算する関数addがあります。

function add (x, y){
 return x + y;
}

function subtract(x, y){