Releases: Tencent/omi
Releases · Tencent/omi
v7.7.0
v7.6.18
v7.6.6
Using v1.0.2 of reactive-signal
v7.5.6
Function component is supported! 🎉
function ChildComponent(props) {
return (
<span>{props.msg}</span>
)
}
class ParentComponent extends Component {
render() {
return (
<div>
<ChildComponent msg="omi" />
</div>
)
}
}
More concise static props definitions for cross framework use🎉
import { tag, Component, h, bind } from 'omi'
@tag('my-counter')
class MyCounter extends Component {
static props = {
count: {
type: Number,
default: 0,
changed(newValue, oldValue) {
this.state.count = newValue
this.update()
}
}
}
state = {
count: null
}
install() {
this.state.count = this.props.count
}
@bind
sub() {
this.state.count--
this.update()
this.fire('change', this.state.count)
}
@bind
add() {
this.state.count++
this.update()
this.fire('change', this.state.count)
}
render() {
return (
<>
<button onClick={this.sub}>-</button>
<span>{this.state.count}</span>
<button onClick={this.add}>+</button>
</>
)
}
}
Using constructor as tag name
import { Button } from './button'
class MyApp extends Component {
render() {
return (
<Button>test</Button>
)
}
}
v7.3.10
Lazy definition
If we are writing a component library and need to use tree shaking capabilities,
import { WeButton } from 'ui-lib'
It could lead to definition failure if Button is not used, as it would be tree-shaken away. Therefore, we need to use Button, for example,
WeButton.define('we-button')