What type of PR is this? (check all applicable)
- Refactor
- Feature
- Bug Fix
- Optimization
- Documentation
import * as Yup from "yup"; | |
const values = 0; | |
const msg = "value should be multiple of hundred"; | |
Yup.addMethod(Yup.number, "multipleOfHundred", function(msg) { | |
return this.test("test-name", msg, function(value) { | |
const { path, createError } = this; | |
return value % 100 === 0 && value !== 0; |
import { useState } from "react"; | |
import { useForm } from "react-hook-form"; | |
function MyForm() { | |
const { register, handleSubmit } = useForm({ | |
defaultValues: { | |
title: "", | |
description: "" | |
} | |
}); |
[ | |
{ | |
"type":"Component", | |
"id":"ImageAndText", | |
"label":"Image and Text", | |
"internal":false, | |
"isGlobal":false, | |
"allowNestedComponents":true, | |
"description":"Image and Text Row", | |
"attributes":{ |
[{"type":"Component","id":"ImageAndText","label":"Image and Text","internal":false,"isGlobal":false,"allowNestedComponents":true,"description":"Image and Text Row","attributes":{"image":{"type":"Image","label":"Image","url":{"type":"String","label":"URL","default":""},"altText":{"type":"String","label":"Alt text","default":""}},"title":{"type":"String","label":"Title","default":""},"description":{"type":"String","label":"Description","default":""},"ctaText":{"type":"String","label":"Button text","default":""},"ctaLink":{"type":"String","label":"Button link","default":""},"boxes":{"type":"Array","label":"box","default":[],"allowNestedComponents":true,"children":{"type":"Shape","default":{},"children":{"title":{"type":"String","label":"box title","default":"box"}}}},"buttons":{"label":"my button","type":"Array","default":{},"allowNestedComponents":false,"children":{"type":"Shape","default":{},"children":{"buttonTitle":{"type":"String","label":"box title","default":""}}}}}},{"type":"Component","id":"RichText","l |
// reduce | |
Object.defineProperty(Array.prototype, 'myReduce', { | |
value: function(fn, initial) { | |
let values = this; | |
values.forEach((item, idx) => { | |
initial = fn(initial, item, idx) | |
}) | |
return initial; |
function getMilliseconds(date) { | |
const [hourse, minute] = date.split(':') | |
return hourse*60*60 + minute*60 | |
} | |
function sortingFn (a, z) { | |
return getMilliseconds(a[0]) - getMilliseconds(z[0]) | |
} | |
function combinedDrivers(city1, city2) { |
:not(figure) > figcaption, | |
:not(fieldset) > legend, | |
:not(dl) > :is(dt, dd), | |
:not(tr) > :is(td, th), | |
:not(select) > :is(option, optgroup), | |
:not(table) > :is(thead, tfoot, tbody, tr, colgroup, caption) { | |
outline: 2px dotted red; | |
} |
// file: pages/blog/[slug].js | |
import React from "react"; | |
function BlogPostPage(props) { | |
return ( | |
<div> | |
<h1>{props.blog.title}</h1> | |
<section dangerouslySetInnerHTML={{ __html: props.blog.content }}></section> | |
</div> | |
); |
import React from "react"; | |
import Link from "next/link"; | |
function IndexPage(props) { | |
return ( | |
<div> | |
<h1>Blog list</h1> | |
<ul> | |
{props.blogs.map((blog, idx) => { | |
return ( |