Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

nornj-react

joe-sky121MIT5.3.5TypeScript support: included

React bindings for NornJ template engine.

nornj, nj, template, react

readme

NornJ-React

React bindings for NornJ template engine.

NPM Version NPM Downloads

Install

npm install nornj-react

bindTemplate

You can use bindTemplate to register React components to NornJ template engine.

  • Class components
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import nj from 'nornj';
import { bindTemplate } from 'nornj-react';

@bindTemplate
class TestComponent extends Component {
  render() {
    return <i>{this.props.children}</i>;
  }
}

ReactDOM.render(nj`<TestComponent>test</TestComponent>`(), document.body);

In addition, bindTemplate also support a name parameter:

...
import { bindTemplate } from 'nornj-react';

@bindTemplate('test-Component')
class TestComponent extends Component {
  render() {
    return <i>{this.props.children}</i>;
  }
}

ReactDOM.render(nj`<test-Component>test</test-Component>`(), document.body);
  • Function components
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import nj from 'nornj';
import { bindTemplate } from 'nornj-react';

const TestComponent = bindTemplate('test-Component')(props => (
  <i>{props.children}</i>
));

ReactDOM.render(nj`<test-Component>test</test-Component>`(), document.body);

License

MIT

changelog

CHANGELOG

[v5.3.1] 2021.02.04

  • 🏷️ Fix useFormData type.

[v5.3.0] 2020.12.30

  • 🌟 Add useFormData hook.
  • 🐛 Support <each> and <></> in <mobxFormData> children.

[v5.2.8] 2020.09.16

  • 🌟 ES module adaptation.

[v5.2.0] 2020.07.08

  • 🌟 mobxFormData tag official released.

[v5.0.1] 2019.12.04

  • 🏷️ Change the React.ElementType to the NornJ.ElementType in type definitions.

[v5.0.0] 2019.12.03

  • 🚩 Support complete typescript type definition.

[v5.0.0-rc.13] 2019.07.22

  • 🌟 Upgrade antd components to latest version.

[v5.0.0-rc.4] 2019.05.05

  • 🌟 n-mobxBind support the native multiple select, checkbox and radio.

[v5.0.0-rc.2] 2019.04.14

  • 🌟 Add MobxObserver tag.

[v5.0.0-beta.5] 2019.03.15

[v5.0.0-beta.1] 2019.03.13

  • 🌟 增加注册ant-design组件到NornJ模板。

[v5.0.0-alpha.3] 2019.03.07

  • 🌟 打包工具由webpack改为rollup

[v0.4.7] 2019.01.18

  • 🌟 mobx-bind指令支持 react-native 的TextInput组件。

[v0.4.6] 2018.12.29

  • 🌟 增加nornj-react/mobx/native

[v0.4.5] 2018.10.17

  • 🌟 改进mobx-bind,调用 action 时增加传事件参数。

[v0.4.4] 2018.09.05

  • 🌟 mobx-model更名为mobx-bind(mobx-model 仍可用),功能优化及代码简化。

[v0.4.3] 2018.08.10

[v0.4.2-rc.9] 2018.03.30

  • 🌟 构建nornj-react-reduxnornj-react-mobxnornj-react-router等扩展包。
  • 🌟 完善mobx-model行内扩展标签,支持更多组件。

[v0.4.2-rc.3] 2018.03.22

  • 🌟 增加mobx-model行内扩展标签。