Skip to content

Instantly share code, notes, and snippets.

View savelichalex's full-sized avatar

Alexey Savelev savelichalex

View GitHub Profile
function ButtonToBottom() {
return (
<ScrollView
style={[
{ flex: 1 },
styles.verticallyInverted,
]}
>
<View style={styles.verticallyInverted}>
<Button title="Press me" />
platform :ios, '9.1'
abstract_target 'Foo' do
# RN related
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'CxxBridge',
'RCTAnimation',
'RCTBlob',
'RCTText',
{
"presets": [["@babel/preset-env", { useBuiltIns: "entry" }]]
}
const NotifReconciler = new NotificationReconciler();
// add some notification to schedule
NotifReconciler.process([
new MyNotification({ date: "01/01/2018", message: "Hello World", id: 1 }),
new MyNotification({ date: "01/02/2018", message: "Hello World2", id: 2 }),
]);
// second notification not needed now
const arraysDiff = (first, second, key) => {
const keysInFirst = first.reduce((acc, item) => {
const id = item[key];
acc[id] = item;
return acc;
}, {});
const { common, added } = second.reduce(
import React from "react";
const linkBlock = "\\[[^\\]]*]\\([^\\)]*\\)";
const linkGrouped = "\\[([^\\]]*)]\\(([^\\)]*)\\)";
const linkRegex = new RegExp(`^${linkGrouped}$`);
const variableBlock = "\\{[^\\}]*\\}";
const variableGrouped = "\\{([^\\}]*)\\}";
const variableRegex = new RegExp(`${variableGrouped}`, "g");
class Immutable {
constructor(of) {
Object.keys(of).forEach(key => Object.defineProperty(this, key, { enumerable: true, get: () => this.of[key] }));
Object.defineProperty(this, "of", { enumerable: false, get: () => of });
}
set(key, value) {
return new this.constructor({ ...this.of, [key]: value });
}
}
const normalizeChatAsync = ({ Messages, Users, ...rest }) => {
let messagesIds = [];
let usersIds = [];
return new Promise((resolve) => {
Promise.all(
Messages.map(
mes => Promise.resolve(mes)
.then(mes => mes.id)
)
// some-js-file.js
export const myFunctionToTestWithRNFS = (fs) => {
fs.readDir(...);
};
// some-file-when-use-rnfs.js
import RNFS from 'react-native-fs';
import { myFunctionToTestWithRNFS } from './some-js-file.js';
myFunctionToTestWithRNFS(RNFS);
#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>
@interface HeadsetDetector : RCTEventEmitter <RCTBridgeModule>
@end