[React] Preview and edit a component live with React Live
In this lesson we'll use React Live to preview and edit a component directly in the browser. React Live is a great tool for rendering interactive documentation or any place you would like to demonstrate a React component with a live preview and editing capabilities.
Additional Resources https://github.com/FormidableLabs/react-live
Install:
npm i react-live --save
Code:
import React from 'react';
import {LiveEditor, LivePreview, LiveError, LiveProvider} from 'react-live'; const code = `
class App extends React.Component {
render() {
return (
<div className="App">
<header className="App-header">
<h1 className="App-title">Welcome to React</h1>
</header>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
</div>
);
}
}`; const AppLive = () => (
<LiveProvider code={code} >
<LiveEditor />
<LivePreview />
<LiveError />
</LiveProvider>
); export default AppLive;
It can work with mdx-deck in presentation: Github

[React] Preview and edit a component live with React Live的更多相关文章
- [React] Use React.memo with a Function Component to get PureComponent Behavior
A new Higher Order Component (HOC) was recently released in React v16.6.0 called React.memo. This be ...
- [React] Refactor a Stateful List Component to a Functional Component with React PowerPlug
In this lesson we'll look at React PowerPlug's <List /> component by refactoring a normal clas ...
- Wait… What Happens When my React Native Application Starts? — An In-depth Look Inside React Native
Discover how React Native functions internally, and what it does for you without you knowing it. Dis ...
- React与ES6(四)ES6如何处理React mixins
React与ES6系列: React与ES6(一)开篇介绍 React和ES6(二)ES6的类和ES7的property initializer React与ES6(三)ES6类和方法绑定 React ...
- react看这篇就够了(react+webpack+redux+reactRouter+sass)
本帖将对一下内容进行分享: 1.webpack环境搭建: 2.如何使用react-router: 3.引入sass预编译: 4.react 性能优化方案: 5.redux结合react使用: 6.fe ...
- 玩转 React 【第03期】:邂逅 React 组件
上期回顾 前文我们讲解了 React 模板 JSX,接着我们继续来看看 React 组件又是如何工作的呢? 组件化开发到了今天已经是大家的共识,在 React 中,组件同样也是组成我们整个项目的基本单 ...
- [React] Use the Fragment Short Syntax in Create React App 2.0
create-react-app version 2.0 added a lot of new features. One of the new features is upgrading to Ba ...
- react,react-router,redux+react-redux 构建一个React Demo
创建初始化应用 加速我们的npm. npm install -g cnpm --registry=https://registry.npm.taobao.org 利用create-react-app ...
- 【React自制全家桶】一、Webstrom+React+Ant Design+echarts搭建react项目
前言 一.React是Facebook推出的一个前端框架,之前被用于著名的社交媒体Instagram中,后来由于取得了不错的反响,于是Facebook决定将其开源.出身名门的React也不负众望,成功 ...
随机推荐
- Vue全局添加组件或者模块
import Api from './api.js' export default { install (Vue) { Vue.prototype.$Api = Api } } 这种格式就可以在mai ...
- C#斐波那契数列递归算法
public static int Foo(int i) { if (i < 3) { return 1; ...
- 在PetaPoco中使用Where in
之前一直没在意,今天查了很多资料,才知道在petapoco中使用in关键字需要使用命名参数,否则是无效的(或者只查出第一个条件的记录),示例如下: var tags= new string[]{“c1 ...
- Importing Objective-C into Swift
Overview You can use Objective-C and Swift files together in a single project, no matter which langu ...
- jQuery radio 选中提示
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- luogu 4884 多少个1?
题目描述: 给定整数K和质数m,求最小的正整数N,使得 11111⋯1(N个1)≡K(mod m) 说人话:就是 111...1111 mod m =K 题解: 将两边一起*9+1,左边就是10^an ...
- laydate组件选择时间段的判断
前言: 在使用laydate组件的时候,难免会遇到选择时间段,官网给的文档中有选择时间段的组件,但是并不好用,首先只能选择一个月的时间段,有局限性,其次精确到时间的话要先选日期范围再选时间范围,很变态 ...
- Django, one-to-many, many-to-many
1.定义关系 定义三个表,Publisher,Book,Author 一个作者有姓,有名及email地址. 出版商有名称,地址,所在城市.省,国家,网站. 书籍有书名和出版日期. 它有一个或多个作者( ...
- json pickle shelve hashlib collections time
import json # Json模块提供了四个功能:dumps.dump.loads.load dic = {'k1':'v1','k2':'v2','k3':'v3'} str_dic = js ...
- admin源码之url设计
如何实现批量设计url? 1.创建Django项目 2.新建app01 和 app02 3.在models.py中创建模型 4.在settings.py中完成数据库配置.app配置等 5.数据库迁移 ...