Skip to content

Instantly share code, notes, and snippets.

View dmail's full-sized avatar
🍒

Damien Maillard dmail

🍒
  • Antibes
View GitHub Profile
@dmail
dmail / add_child_props.jsx
Last active February 17, 2025 14:11
Pass props to child from parent in preact
import { cloneElement, toChildArray } from "preact";
const AutoTargetBlank = ({ children }) => {
children = toChildArray(children);
return (
<div>
{children.map((child) => {
return cloneElement(child, { target: '_blank' });
})}
</div>
// ESM version of "[email protected]"
// https://github.com/pillarjs/path-to-regexp/blob/master/package.json
/**
* Tokenize input string.
*/
function lexer(str) {
var tokens = [];
var i = 0;
while (i < str.length) {