Skip to content

Instantly share code, notes, and snippets.

View jdjuan's full-sized avatar
:octocat:

Juan Herrera jdjuan

:octocat:
View GitHub Profile
@jdjuan
jdjuan / react.md
Last active April 3, 2023 16:02
React Setup

React Lessons

  • Use Recoil for state management early on. It's too simple not to do it
  • Falsy values still render in in-line conditions. Always !! expressions that might not be boolean
  • Use default values for Enums, or ordering will change values
  • With event handlers, make sure to use an arrow function to avoid having to use .bind
  • If you want a component not to render, return null
  • Create interfaces first for the backend and the frontend
  • Define components (p, h1,h2,h3,h4) and mark them in the designs (with variants)
  • Put links in a common place
@jdjuan
jdjuan / one-trust.ts
Created September 22, 2022 14:27
Read OneTrust Cookies
const cookie =
"'WATRC=2D0FDD6D-6F29-49E6-AEE0-42080FAA8120; _ga_6NJJBYQCBV=GS1.1.1658756504.1.1.1658756505.59; _gcl_au=1.1.2054335917.1659447846; _ga_Y9TTEFYVZC=GS1.1.1662476698.1.1.1662478229.0.0.0; _ga_TW3TH3JW1S=GS1.1.1662477516.1.1.1662478229.0.0.0; _ga_M0YDYEWKG9=GS1.1.1662477395.1.1.1662478229.0.0.0; _ga_MF7T4Q7V2G=GS1.1.1662477370.1.1.1662478229.0.0.0; _ga_ZE6FQL0YJS=GS1.1.1663668306.2.1.1663668449.0.0.0; _ga=GA1.2.402987297.1658756505; _gid=GA1.2.534896851.1663742869; WANV=AA2512FF-2F73-448D-8675-6A3DA6184C9F; OptanonAlertBoxClosed=2022-09-22T07:22:21.804Z; OptanonConsent=isGpcEnabled=0&datestamp=Thu+Sep+22+2022+09%3A22%3A22+GMT%2B0200+(Mitteleurop%C3%A4ische+Sommerzeit)&version=6.36.0&isIABGlobal=false&hosts=&consentId=f51c839a-cd58-489e-9f9c-e8a6e3931a0d&interactionCount=8&landingPath=NotLandingPage&groups=C0001%3A1%2CC0002%3A0%2CC0004%3A0&geolocation=%3B&AwaitingReconsent=false'";
function getOneTrustGrants(cookies) {
const escapedCookies = decodeURIComponent(cookies);
const result = escape