JSXを私の還元状態、つまりグローバルに使用されるモーダルコンポーネントに対してどのように渡すかを調べるのに問題があります。その1つのパラメータがcontent
の場合は還元状態です。 JSXコードを含むように更新されました。次のエラーの多いjsxコンテンツを還元状態にしてそこからレンダリングする
invariant.js:38 Uncaught Error: Objects are not valid as a React child (found: object with keys {dispatchConfig, _targetInst, isDefaultPrevented, isPropagationStopped, _dispatchListeners, _dispatchInstances, nativeEvent, type, target, currentTarget, eventPhase, bubbles, cancelable, timeStamp, defaultPrevented, isTrusted, view, detail, screenX, screenY, clientX, clientY, ctrlKey, shiftKey, altKey, metaKey, getModifierState, button, buttons, relatedTarget, pageX, pageY}). If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons. Check the render method of
styled.div
.
::私はしかし、関数が正しく呼び出されて、私はまた、次のエラーを取得していますように見えていません、それは正しいコンテンツをレンダリングするために取得しています現時点では
warning.js:36 Warning: This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the property
nativeEvent
on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist(). See https://fbme(replaced this as so doesn't allow links to fb)/react-event-pooling for more information.
の実装例:モーダルを表示すると続きを追加するページから呼び出さ
機能
export const modalToggle = (content = '') => ({
type: MODAL_TOGGLE,
payload: content
});
私はその後、私のモーダルコンテナ内で、このようなコンテンツをレンダリングしよう:
return (
<div>{this.props.content}</div>
)
私は私にReact
を輸入し、それ
this.props.modalToggle
はこのようなReduxのアクションです
onToggleModal =() => {
this.props.modalToggle(
(<TopUp account={getSession().accounts[0] || {}} />)
);
}
にエントJsxの問題を解決することを望んでいたが、運がなかった。それはコンポーネントが奇妙なオブジェクトのいくつかの並べ替えのような減速機に渡されるようにも思える。
あなたはモーダルと 'redux'パターンを探しているなら、私は非常にこのアプローチを提案します。http://stackoverflow.com/questions/35623656/how-can-i-display-a-mode-dialog-in-redux-that-performing-asynchronous-actions私たちは現在プロダクションでそれを使用しており、非常に安定しています。 – lux
@luxはうまく見えますが、私は小道具として機能を渡すのが難しいです。 – Ilja