Skip to content

Instantly share code, notes, and snippets.

Avatar
🐰
Working from cafe

Yukiya Nakagawa Nkzn

🐰
Working from cafe
View GitHub Profile
@Nkzn
Nkzn / 1_betagaki.tsx
Last active Sep 3, 2020
hooksで状態管理
View 1_betagaki.tsx
import React from 'react';
function Hoge(props) {
const [count, setCount] = React.useState(0);
const [loading, setLoading] = React.useState(false);
const [error, setError] = React.useState(null);
const [onceLoaded, setOnceLoaded] = React.useState(false);
// 初回読み込み
React.useEffect(() => {
@Nkzn
Nkzn / git-pr-diff.rb
Created Aug 11, 2020
Display PRs between commitA and commitB
View git-pr-diff.rb
#! /usr/bin/ruby
# The MIT License (MIT)
# Copyright (c) 2020 Yukiya Nakagawa <yn.airscope@gmail.com>
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWI
@Nkzn
Nkzn / Headline.tsx
Created May 12, 2020
"accessibilityRole: 'heading'" with TypeScript
View Headline.tsx
import React from 'react';
import { StyleProp, TextStyle, StyleSheet } from 'react-native';
import { Headline as PaperHeadline } from 'react-native-paper';
export const Headline = (props: {
style?: StyleProp<TextStyle>;
children: string;
}) =>
React.cloneElement(
<PaperHeadline style={StyleSheet.flatten([styles.headline, props.style])}>
@Nkzn
Nkzn / functions.js
Created Apr 1, 2020
ES Modulesで「プライベートメソッドをテストする」をやりたいとき
View functions.js
export function publicFunction() {
}
function complexPrivateFunctionA() {
}
function complexPrivateFunctionB() {
@Nkzn
Nkzn / README.md
Last active Mar 9, 2020
Pull Request diff list generator (GitLab ver => https://gist.github.com/Nkzn/c2f916ceb972d77138ba)
View README.md

git-pr-diff

Usage

  1. Rename git-pr-diff.rb to git-pr-diff.
  2. Move git-pr-diff into PATH ed folder.
View HybridComponent.tsx
import React from 'react';
import { View, Text } from 'react-native';
import { WebView } from 'react-native-webview';
const HybridComponent: React.FC = () => (
<View>
<Text>Rendering as native text with TextView/UIView</Text>
<WebView>
<View>
<Text>Rendering as DOM tree with WebView/WkWebView</Text>
@Nkzn
Nkzn / milkboy.md
Last active Feb 12, 2020
たぶんPWAの話
View milkboy.md

「うちのお客さんがね、Webサービス作りたいゆーんやけど」

「そうなんや」

「ユーザーへの届け方を忘れたらしいねん」

「ユーザーへの届け方を忘れるってどうなってんねん」

「いろいろ聞くんやけどな、全然わからへんねん」

@Nkzn
Nkzn / ClassComponent.js
Created May 9, 2019
コンポーネントがDOMツリーに書き込まれたタイミングで、Reactの外側にコールバックを実行するサンプル
View ClassComponent.js
import React from 'react';
export default class ClassComponent extends React.Component {
componentDidMount() {
if (this.ref) {
const event = new CustomEvent('initializedWithClassComponent', { detail: this.ref });
window.dispatchEvent(event);
}
}
@Nkzn
Nkzn / Fab.tsx
Last active Apr 23, 2019
自作Floating Action Button
View Fab.tsx
import React from "react";
import {
StyleProp,
StyleSheet,
TouchableWithoutFeedback,
View,
ViewStyle
} from "react-native";
import { colors, dimens } from "./style";