React Lim: Make React easier to use (Lim means 'Less is More')
Docs | Playground | Vue-Lim | 中文
React-lim is a compilation tool that allows you to get rid of using the Hooks. Here's a simple example
export function Counter() {
let count = 1
const increase = ()=> count ++
return <button onClick={increase}>
count is {count}
</button>
}
npm create lim
then choose react-lim
npm i react-lim
import { defineConfig } from 'vite'
import lim from 'react-lim/vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [lim(), react()],
// ...
})
import lim from 'react-lim/rollup'
export default {
plugins: [
lim(),
// Introduce react related plug-ins by yourself
]
};
import lim from 'react-lim/esbuild'
import { build } from 'esbuild';
build({
plugins: [
lim(),
// Introduce react related plug-ins by yourself
],
});
module.exports = {
module: {
rules: [{
test: /(\.[tj]sx)$/,
loader: 'react-lim/webpack',
exclude: /node_modules/
}]
// Introduce react related loaders by yourself
}
}
When using .lim.tsx
or .lim.jsx
as the file suffix, lim compilation will be enabled
When using only .tsx
or .jsx
, you need to add 'use lim'
or // use lim
in the file header to enable lim compilation
import { transformReact } from 'react-lim';
console.log(transformReact(`// some react code`));
This API can be used in a web environment
<script src='https://cdn.jsdelivr.net/npm/react-lim'></script>
<script>
console.log(ReactLim.transformReact(`// some react code`));
</script>