Skip to content

Instantly share code, notes, and snippets.

View hosembafer's full-sized avatar
💭
I may be slow to respond.

Rafayel Hovhannisyan hosembafer

💭
I may be slow to respond.
View GitHub Profile
@hosembafer
hosembafer / react-native-bold.js
Created April 15, 2018 20:46
React Native Bold
const B = (props) => <Text style={{fontWeight: "bold"}}>{props.children}</Text>;
// ...
<Text>This is a sentence <B>with</B> one word in bold</Text>
@hosembafer
hosembafer / index.js
Created June 11, 2018 10:40
react-day-picker range + single days selection
import React from "react";
import ReactDOM from "react-dom";
import DayPicker from "react-day-picker";
import DayPickerInput from "react-day-picker/DayPickerInput";
import "react-day-picker/lib/style.css";
class Example extends React.Component {
state = {
{
data: {
pageTitle: 'VEELGESTELDE VRAGEN',
pageIconUuid: 'cd34154b-d009-44f8-81ae-0c080ccbb0a5',
questions: [
{
title: 'Faq title 1',
text: 'Faq description text 1',
},
{
{
data: {
headTitle: 'HOE WERKT?',
headText: 'HOE WERKT?HOE WERKT?HOE WERKT?HOE WERKT?',
headIconUuid: 'acef632f-e28f-44cd-bc6a-31a22d49f1f8',
videoUrl: 'https://www.youtube.com/watch?v=CIpOxa5hxOw',
steps: [
{
title: 'Step 1',
text: 'Step 1 long text',
var segments = [
{
value: 'content-partner',
type: 'STATIC',
part: 'PATH',
},
{
value: 'content partner name 111',
type: 'DYNAMIC',
entity: 'CONTENT_PARTNER',
@hosembafer
hosembafer / useSwipeToDismiss.js
Created April 25, 2019 14:22
react-swipe-to-dismiss: useSwipeToDismiss.js
import {useCallback, useEffect, useState} from 'react';
const useSwipeToDismiss = (ref, onDismiss, removeDOM = false, distanceBeforeDismiss = 100, direction = 'right') => {
const node = ref.current;
const [removing, setRemoving] = useState(false);
const [pressedPosition, setPressedPosition] = useState(false);
const [positionLeft, setPositionLeft] = useState(false);
const [animate, setAnimate] = useState(false);
const [opacity, setOpacity] = useState(1);
@hosembafer
hosembafer / SwipeToDismiss.js
Created April 25, 2019 14:23
react-swipe-to-dismiss: SwipeToDismiss.js
import React from 'react';
import PropTypes from 'prop-types';
import { findDOMNode } from 'react-dom';
class SwipeToDismiss extends React.Component {
constructor(props) {
super(props);
this.node = null;
@hosembafer
hosembafer / App.js
Last active April 25, 2019 14:25
react-swipe-to-dismiss: App.js
const MessageItem = ({message, onDismiss}) => {
const ref = useRef(null);
const swipeableMessageProps = useSwipeToDismiss(ref, onDismiss, false, 100, 'right');
return <div ref={ref} className={'Message'} {...swipeableMessageProps}>
{message}
</div>;
};
import { useTodoListStore } from '../../store/TodoListStore';
const TodoList = () => {
const {
tasks,
addTask,
renameTask,
removeTask,
} = useTodoListStore();
import React, { useState, useCallback } from 'react';
const Context = React.createContext();
let nextId = 0;
export const TodoListProvider = ({children}) => {
const [tasks, setTasks] = useState([]);
const addTask = useCallback(name => setTasks(tasks => ([...tasks, {id: ++nextId, name}])), [setTasks]);