Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 861 Bytes

with-props.md

File metadata and controls

45 lines (33 loc) · 861 Bytes

With props

The function withPropsfrom the npm package evokit, set the default props for block


Usage

For examples, consider the use on the Link block.

import { withProps } from 'evokit';
import { Link } from 'evokit-link';

const LinkNofollow = withProps(Link, {
    'link-color': 'gray',
    rel: 'nofollow'
});

// input:
<LinkNofollow href='#' />
// output:
<a href='#' class='ek-link ek-link_color_gray' rel='nofollow' />

Override default props:

// input:
<LinkNofollow href='#' link-color='red' rel='help' />
// output:
<a href='#' class='ek-link ek-link_color_red' rel='help' />

Remove default props:

// input:
<LinkNofollow href='#' link-color={null} rel={null} />
// output:
<a href='#' class='ek-link' />