Skip to content

Instantly share code, notes, and snippets.

View reggie3's full-sized avatar

Reginald Johnson reggie3

View GitHub Profile
/*****************************************
* uploadPicturesToBucketV2
* CURRENT WORKING VERSION
* post base64 encoded data to server
* This works when used in conjunction with technique from this post:
* http://stackoverflow.com/questions/26805005/sending-binary-data-to-amazon-s3-javascript
*/
export const uploadPicturesToBucket = (fileArray, userId, jwt, loginType) => {
let promiseArray = fileArray.map((file, index, array) => {
@reggie3
reggie3 / prop-state-diff.jsx
Created June 14, 2019 18:10
Find differences in react prop and state updates
public componentDidUpdate(prevProps, prevState) {
console.log('Rrow update diff:');
const nowProps = Object.entries(this.props);
const addedProps = nowProps.filter(([key, val]) => {
if (prevProps[key] === undefined) {
return true;
}
if (prevProps[key] !== val) {
@reggie3
reggie3 / sharedRenderProp.js
Created October 19, 2018 19:23
passing props to shared render prop
<CreateNewLocationMediaItemRP
// pass redux dispatch and actions to the RP to receive as props
dispatch={this.props.dispatch}
actions={actions}
// Use callbacks so that platform specific methods can call a function
// in the RP.
// The callback is a function passed from the RP to this component.
// This enables the platform specific function this.takeNewPictureOrVideo can
// call a function in the RP.
@reggie3
reggie3 / app.json
Last active October 19, 2018 19:15
app.json packagerOpts for shared imports
"packagerOpts": {
"projectRoots": "",
"config": "rn-cli.config.js",
},
@reggie3
reggie3 / gatsby-node.js
Created October 19, 2018 19:12
Gatsby js config for shared imports
exports.modifyWebpackConfig = ({ config, _stage }) => {
console.log("*********config._config.context: ", config._config.context)
return config.merge({
resolve: {
alias: {
shared: path.resolve(config._config.context, '../shared'),
},
},
})
}
@reggie3
reggie3 / rn-cli.confg.js
Last active March 1, 2019 09:30
rn-cliconfig.js for shared projects
const path = require('path');
module.exports = {
// For React Native version 0.57
projectRoot: path.resolve(__dirname),
// tell the builder to also look in the shared directory for imports
watchFolders: [
path.resolve(__dirname, "../shared")
]
@reggie3
reggie3 / sendMessage.js
Last active June 22, 2018 18:04
Webview sendMessage function
<Map
style={{
width: '100%',
backgroundColor: 'lightblue'
}}
...
// handling a react-leaflet map click event
onClick={(event) => {
this.onMapEvent('onMapClicked', {
coords: [event.latlng.lat, event.latlng.lng]
@reggie3
reggie3 / handle.js
Last active June 22, 2018 17:43
webview parent component handle message gist
handleMessage = (event) => {
let msgData;
try {
msgData = JSON.parse(event.nativeEvent.data);
if (
msgData.hasOwnProperty('prefix') &&
msgData.prefix === MESSAGE_PREFIX
) {
console.log(`WebViewLeaflet: received message: `, msgData.payload);
@reggie3
reggie3 / gist:281764f555bb65138e096f636bacba0a
Last active June 6, 2018 00:28
Problem With Animation
import React, { Component } from 'react';
import {
View,
StyleSheet,
Modal,
Keyboard,
KeyboardAvoidingView,
Animated,
TouchableWithoutFeedback,
Easing
soundRecorderComplete = (soundFileInfo) => {
soundFileInfo =
typeof soundFileInfo === 'object'
? JSON.stringify(soundFileInfo, undefined, 2)
: soundFileInfo;
this.setState({
viewToShow: 'home',
soundFileInfo
});