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. node-zookeeper-dubbo 和egg实现远程连接

    基于js的node-zookeeper-dubbo 和egg实现远程连接服务 const nzd = require('node-zookeeper-dubbo'); const opt={ appl ...

  2. 【mysql学习-2】

    part-1: USE mysql;CREATE TABLE tb_x(id INT,NAME CHAR(10));INSERT INTO tb_x VALUES(5,"a");S ...

  3. 误删 EhCache 中的数据?

    最近遇到一个问题:在使用ehcache时,通过CacheManager.getCache(chachename).get(key),获取相应的缓存内对象(当时这个对象是个list), 有个同事写个方法 ...

  4. 网站安全检测 漏洞检测 对thinkphp通杀漏洞利用与修复建议

    thinkphp在国内来说,很多站长以及平台都在使用这套开源的系统来建站,为什么会这么深受大家的喜欢,第一开源,便捷,高效,生成静态化html,第二框架性的易于开发php架构,很多第三方的插件以及第三 ...

  5. Leecode刷题之旅-C语言/python-20.有效的括号

    /* * @lc app=leetcode.cn id=20 lang=c * * [20] 有效的括号 * * https://leetcode-cn.com/problems/valid-pare ...

  6. R语言学习笔记(六): 列表及数据框的访问

    List R语言中各组件的名称叫做标签(tags),访问列表有3种方法: j$salary 通过标签名字访问,只要不引起歧义,可以只写出前几个字母. j[['sal']] 夹在两个中括号时引号里的标签 ...

  7. 登録更新(BAPI)

    購買管理(MM) * [BAPI_REQUISITION_CREATE] 購買依頼登録 * [BAPI_REQUISITION_CHANGE] 購買依頼変更 * [BAPI_REQUISITION_D ...

  8. ionic打包apkFailed to execute shell command "input,keyevent,82"" on device: Error: adb: Command failed with exit code 137

    错误代码如下 BUILD SUCCESSFUL in 12s 46 actionable tasks: 1 executed, 45 up-to-date Built the following ap ...

  9. 基于Ubuntu Server 16.04 LTS版本安装和部署Django之(一):安装Python3-pip和Django

    近期开始学习基于Linux平台的Django开发,想配置一台可以发布的服务器,经过近一个月的努力,终于掌握了基于Apache和mod-wsgi插件的部署模式,自己也写了一个教程,一是让自己有个记录,二 ...

  10. 关于 spring-aop理解

    对于Aop 一直理解很是不到位  谈谈自己理解! Aop : Aspect: 切面    joinpoint 连接点  pointCut 切点  Advice 增强  targert 目标对象   w ...