React & styled component

https://www.styled-components.com/#your-first-styled-component

tagged template literals

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates

https://www.styled-components.com/docs/advanced#tagged-template-literals


let person = 'Mike';
let age = 28;

const myTag = (strings, personExp, ageExp) => {
    let str0 = strings[0]; // "That "
    let str1 = strings[1]; // " is a "
    // There is technically a string after
    // the final expression (in our example),
    // but it is empty (""), so disregard.
    // var str2 = strings[2];
    let ageStr;
    if (ageExp > 99) {
        ageStr = 'centenarian';
    } else {
        ageStr = 'youngster';
    }

    // We can even return a string built using a template literal
    return `${str0}${personExp}${str1}${ageStr}`;
}

let output = myTag`That ${person} is a ${age}`;

console.log(output);
// That Mike is a youngster

React & styled component的更多相关文章

  1. react slot component with args

    react slot component with args how to pass args to react props child component https://codesandbox.i ...

  2. react hooks & component will unmount & useEffect & clear up

    react hooks & component will unmount & useEffect & clear up useEffect & return === u ...

  3. [React] Create component variations in React with styled-components and "extend"

    In this lesson, we extend the styles of a base button component to create multiple variations of but ...

  4. [React Fundamentals] Component Lifecycle - Updating

    The React component lifecycle will allow you to update your components at runtime. This lesson will ...

  5. [React Fundamentals] Component Lifecycle - Mounting Usage

    The previous lesson introduced the React component lifecycle mounting and unmounting. In this lesson ...

  6. [React Fundamentals] Component Lifecycle - Mounting Basics

    React components have a lifecycle, and you are able to access specific phases of that lifecycle. Thi ...

  7. [React] React Fundamentals: Component Lifecycle - Updating

    The React component lifecycle will allow you to update your components at runtime. This lesson will ...

  8. [React ] React Fundamentals: Component Lifecycle - Mounting Usage

    The previous lesson introduced the React component lifecycle mounting and unmounting. In this lesson ...

  9. [React] React Fundamentals: Component Lifecycle - Mounting Basics

    React components have a lifecycle, and you are able to access specific phases of that lifecycle. Thi ...

随机推荐

  1. Linux下文件字符编码格式检测和转换

    目前多数情况下, 我们遇到的非英文字符文件都是使用UTF-8编码的, 这时一般我们查看这些文件的内容都不会有问题. 不过有时, 我们有可能会遇到非UTF-8编码的文件, 比如中文的GBK编码, 或者俄 ...

  2. 【mvrp多协议vlan注册协议给予三种注册方式的验证】

    MVRP 多vlan注册协议给予三种注册模式的配置 一:根据项目需求搭建好拓扑图如下 二:配置: 首先对项目做理论分析,sw1,sw2,sw3所组成的直连网络中,为使不同的PC之间进行通信,按vlan ...

  3. 【poe设备加电配置】

    开启接口的poe功能: [interface_name]: 配置poe端口的最大功率: [interface_name[: 配置poe的端口工作模式: [interface_name[: 配置poe端 ...

  4. 谈谈toLocaleString()

    如何理解toLocaleString()? toLocaleString()就是把数组转换为本地字符串.首先调用每个数组元素的toLocaleString()方法,然后使用地区特定的分隔符把生成的字符 ...

  5. python数据类型及其特有方法

    一.运算符 in方法 "hello" in "abcdefghijklmnopqrstuvwxyz" "li" in ["gg&q ...

  6. 怎么修复网站漏洞之metinfo远程SQL注入漏洞修补

    2018年11月23日SINE网站安全检测平台,检测到MetInfo最新版本爆出高危漏洞,危害性较大,影响目前MetInfo 5.3版本到最新的 MetInfo 6.1.3版本,该网站漏洞产生的主要原 ...

  7. PAT-A1002

    1002 A+B for Polynomials (25) Polynomials多项式,exponents指数,coefficients系数 输入:两行数据,每行表示一个多项式:第一个数字表示非零项 ...

  8. Mongoose模式的扩展

    模式的扩展 默认值 默认值的类型: 固定值.即使生成 代码展示: var mongoose = require('mongoose');mongoose.connect('mongodb://loca ...

  9. 【Leetcode】413. Arithmetic Slices

    Description A sequence of number is called arithmetic if it consists of at least three elements and ...

  10. 常用js方法合集

    var Default = { init: function () { }, addCookie: function (name,data) { var expdate = new Date(); / ...