最佳实践
条件渲染
如果想要根据条件渲染显示视图,请务必无条件地渲染 ReactNavigationPerformanceView
。您可以参考以下示例
ts
// Property determining which component is renderedlet componentNumber = 0;// Component0 and Component1 should not be wrapped in `ReactNavigationPerformanceView`const childView = componentNumber === 0 ? <Component0 /> : <Component1 />;<ReactNavigationPerformanceView screenName="MyScreen" interactive renderPassName={`interactive_${componentNumber}`}>{childView}</ReactNavigationPerformanceView>;
ts
// Property determining which component is renderedlet componentNumber = 0;// Component0 and Component1 should not be wrapped in `ReactNavigationPerformanceView`const childView = componentNumber === 0 ? <Component0 /> : <Component1 />;<ReactNavigationPerformanceView screenName="MyScreen" interactive renderPassName={`interactive_${componentNumber}`}>{childView}</ReactNavigationPerformanceView>;