0
可能な限り一般的な単純なWizard
コンポーネントを作成したいと考えています。リアクションのダイナミックテンプレート
身体内容のための2つのパラメータ:template
(ロジックを含む)とそのcontext
を注入したいと思います。
export class ParentClass extends React.Component {
render() {
let template = `Some text: {this.context.testFunc()}`;
let context = new TestContext();
return (
<Wizard template={template} context={context} />
);
}
}
export class TestContext {
testFunc() {
return "another text";
}
}
export class Wizard extends React.Component {
context: null;
constructor(props) {
super(props);
this.context = this.props.context;
}
render() {
return (
<div>
{this.props.template}
</div>
);
}
}
問題は、(それがWizard
に文字列として、すべてを書き込み)を実行していないtemplate
に含まロジックです。
コンパイルにはES2015
とBabel
を使用します。