[React] Preview and edit a component live with React Live
2024-08-30 19:04:49
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
最新文章
- twobin博客样式—“蓝白之风”
- [No00002E]关于大数据,你不知道的6个迷思
- autolayout autoresizing
- Pyqt 打包资源文件
- [转]Java 8:不要再用循环了
- .NET 实现自定义ContextUser的Identity和Principal实现自定义用户信息,权限验证。
- c库函数之scanf
- Android Studio ndk-Jni开发详细
- NOIP 2015 子串
- The Building Blocks-Enterprise Applications Part 2- Information Management and Business Analytics
- OCP读书笔记(26) - 题库(ExamF)
- Dynamics CRM 警惕Odata查询的陷阱
- springcolud文章收藏
- shell 命令 if elif else fi 用法
- 利用python计算多边形面积
- 美食查询手机应用";吃了么";:NABC
- js 触发 change 事件
- Dream------scala--函数定义、流程控制、异常处理
- ZH奶酪:IBG项目工作内容
- go_接口