Skip to content

Instantly share code, notes, and snippets.

@ysfzrn
ysfzrn / draftForm.js
Created March 7, 2017 17:33
draft js to html || from html
import React, { Component } from 'react';
import { Editor } from 'react-draft-wysiwyg';
import { ContentState,EditorState,convertFromHTML } from 'draft-js';
import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
import {stateToHTML} from 'draft-js-export-html';
const toolbar = {
options: ['inline', 'fontSize','list', 'colorPicker', 'link', 'emoji', 'history'],
}
@ysfzrn
ysfzrn / Promise.js
Created March 8, 2017 14:45
Then-able Duck Typing-
-----Then-able Duck Typing------------
Promise dünyasında en önemli şey, bir değişkenin gerçek bir Promise olup,olmadığına
karar vermek ya da bir Promise gibi davranış sergileyecek mi onu anlamak.
new Promise(...) syntax ı ile verilen Promise lerin,
'p instanceof Promise' bu şekilde kontrolünü yapabileceğini düşünebilirsin ama tam
oarak bu yaklaşım doğru olmayabilir.
Mesela sen başka bir window dan iframe gibi yerlerden Promise alabilirsin. O zaman
'p instanceof Promise' kontrolü başarısız olacaktır.
@ysfzrn
ysfzrn / app.js
Created March 8, 2017 14:46
reactnativequicenotes
React Native Quick Notes
-----------------------------------------
<View onLayout={this._handleLayout} />
------------------------------------------------------------
onLayout { nativeEvent : { layout: {x, y, width, height} } }
-This event is fired immediately once the layout has been calculated
-But the new layout may not yet be reflected on the screen at the same time the event is received
(Especially if a layout animation is in progress)
@ysfzrn
ysfzrn / cb.js
Created March 8, 2017 14:46
callbacketc
Trying to Save Callbacks
analytics.trackPurchase(purchaseData,function(){
tracked=true;
chargeCreditCard();
displayThankyouPage();
}
);
@ysfzrn
ysfzrn / RN-Main.jsx
Created March 12, 2017 01:04
React Native Todo List FlexBox Example
'use strict';
import React, { Component } from 'react';
import { StyleSheet,View, Text,TouchableOpacity,
TextInput, Platform } from 'react-native';
class Main extends Component {
render() {
return (
@ysfzrn
ysfzrn / nginx.conf
Last active March 15, 2017 21:27
react-feathers-socket-bypass
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@ysfzrn
ysfzrn / ListView.jsx
Created March 21, 2017 04:18
React Native ListView
//import liraries
import React, { Component } from "react";
import { View, Text, ListView, StyleSheet } from "react-native";
const rows = [
{ id: 1, text: "row1" },
{ id: 2, text: "row2" },
{ id: 3, text: "row3" },
{ id: 4, text: "row4" },
{ id: 5, text: "row5" },
@ysfzrn
ysfzrn / app.js
Created June 4, 2017 15:24
Example LayoutAnimation React Native
//import liraries
import React, { Component } from "react";
import { View, Text, StyleSheet, ScrollView,LayoutAnimation, StatusBar } from "react-native";
import FlexTab from "./flexTab";
import Header from './header'
// create a component
class App extends Component {
constructor() {
super();
this.state = {
import mobx, { observable } from "mobx";
class Store {
@observable todos=[];
@observable selectedStatus="all";
}
const todoStore = new Store()
export default todoStore;
import mobx, { observable, action } from "mobx";
class Store {
@observable todos=[];
@observable selectedStatus="all";
@action('adding todo item')
addTodo(todo){
this.todos.push({
id: this.todos[this.todos.length - 1].id +1,
status: false,
text: todo