Skip to content

Instantly share code, notes, and snippets.

View annjawn's full-sized avatar

Anjan Biswas annjawn

View GitHub Profile
@annjawn
annjawn / customDatepicker.js
Last active December 30, 2021 02:28
Keyboard and Performance friendly Ant Design Datepicker
import React, { Component } from "react";
import { Popover, Input, Calendar, Icon, Select, Button, Col, Row } from "antd";
import debounce from "lodash/debounce";
import moment from "moment";
import "antd/dist/antd.css";
class DatePicker extends Component {
static getDerivedStateFromProps(nextProps) {
// Should be a controlled component.
if ("value" in nextProps) {
@annjawn
annjawn / index.js
Last active December 8, 2018 04:34
React Component to upload file to S3 using AWS Amplify
import React, { Component } from "react";
import ReactDOM from "react-dom";
import { configureAmplify, SetS3Config } from "./services";
import Storage from "@aws-amplify/storage";
import "./styles.css";
class App extends Component {
state = {
imageName: "",
imageFile: "",
@annjawn
annjawn / trustrelation.json
Created December 6, 2018 09:43
Cognito Identity pool Auth role trust relationship with S3
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "cognito-identity.amazonaws.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
@annjawn
annjawn / authpermission.json
Created December 6, 2018 09:34
Cognito identity pool Auth Role Permission for S3
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"mobileanalytics:PutEvents",
"cognito-sync:*",
"cognito-identity:*"
],
@annjawn
annjawn / services_updated.js
Last active December 6, 2018 04:15
Modular import Amplify and configure core and Storage
import Amplify from '@aws-amplify/core';
import Storage from '@aws-amplify/storage';
export function configureAmplify() {
Amplify.configure(
{
Auth: {
identityPoolId: process.env.REACT_APP_identityPoolId,
region: process.env.REACT_APP_region,
userPoolId: process.env.REACT_APP_userPoolId,
@annjawn
annjawn / services.js
Last active December 5, 2018 19:13
Modular import of amplify core
import Amplify from '@aws-amplify/core';
export function configureAmplify() {
Amplify.configure(
{
Auth: {
identityPoolId: process.env.REACT_APP_identityPoolId,
region: process.env.REACT_APP_region,
userPoolId: process.env.REACT_APP_userPoolId,
userPoolWebClientId: process.env.REACT_APP_userPoolWebClientId,