Skip to content

Instantly share code, notes, and snippets.

View pramendra's full-sized avatar
💭
🤓

Pramendra Gupta pramendra

💭
🤓
View GitHub Profile
[
{
"id": 1517441231,
"price": 31,
"image_src":
"https://static-mercariapp-com.akamaized.net/thumb/photos/m62013065965_1.jpg?1517441231",
"name": "BH Cosmetics- Wild & Alluring Palette"
},
{
"id": 1517540022,

Props and cons of using create element

Overview:

  • parent has multiple items and able to sent call back to parent
  • Parent should be able to accept any type of component

with render props

https://jsbin.com/xamoyuxabi/3/edit?js,output

Disadvantages

  • get children and map it as children may have array (which may break)
  • accordion is tightly couple with renderItem making it almost impossible to reuse

Styled component use case

Styled component as standard react component

avoid creating middleware react component

before

const StyledIcon = styled(Icon)``; export const HomeIcon = () => ;

after

export const CameraIcon = styled(Icon)``;

@pramendra
pramendra / getFirstThreeFromArray
Created June 19, 2020 10:26
getFirstThreeFromArray using Ramda
// const { compose, defaultTo, equals, map, slice } = R;
const slice2DArray = (slice) => compose(defaultTo([]), map(slice));
const getFirstThreeFromArray = slice2DArray(slice(0, 3));
const input_data = [
["a", "b", "c", "d"],
["a", "b", "c", "d"],
["a", "b", "c", "d"],
["a", "b"],
["x", "y", "z", "z1"],
const premLeague = R.equals("Prem League");
const premLeagueInArray = R.any(premLeague);
const categories = R.path(["categories"]);
const isPremLeagueInArray = R.pipe(categories, premLeagueInArray);
const teams = [
{ name: "Liverpool", id: "1", categories: ["Prem League"] },
{ name: "Man Utd", id: "2", categories: ["Blue Square"] },
{ name: "Sheff Utd", id: "2", categories: ["Prem League"] },
];