私はReactjs + React-motionプロジェクトを "モーダルウィンドウ"で作業しています(そう言えば)可能なら、コンポーネントを動的にマウントまたはロードしたいのですか?reactjsでコンポーネントを動的にロードする方法は?
これまでの解決策:方法を見つけることができなかったため、コンポーネントを適切に配置して非表示にしてから、クラスまたはスタイルを状態の変更、非表示コンポーネントの表示、 「モーダルウィンドウ」の遷移が終了した後。
私がしようとしていることを理解しやすいところにいくつかのコードを共有しています。イベントハンドラはなく、ほとんどのコードは削除されましたが、onRest
(アニメーションが終了したときのイベントコールバックが公開されています)およびrender fnも削除されました。
class HomeBlock extends React.Component {
constructor (props) {
...
}
...
motionStyleFromTo() {
return {
...
};
}
onRest() {
// this is triggered when the Motion finishes the transition
}
render() {
return (
<Motion onRest={this.onRestCallback.bind(this)} style={this.motionStyleFromTo()}>
{style =>
<div className="content" style={{
width: `${style.width}px`,
height: `${style.height}px`,
top: `${style.top}px`,
left: `${style.left}px`
}}>
[LOAD COMPONENT HERE]
</div>
}
</Motion>
);
}
}
export default HomeBlock;