mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 20:01:01 +08:00
Move stuff out of vendor/react_contrib/
Summary: This was a confusing place for them. BoundingDimensions, Position, and Touchable were only used in Touchable; StaticContainer I moved to Libraries/Components. @public Reviewed By: @vjeux Differential Revision: D2530730 fb-gh-sync-id: e636a6b7259c2bd3ab52c82ebd59a6c66c9e7e7a
This commit is contained in:
committed by
facebook-github-bot-9
parent
264cb8962a
commit
5e33dbcfcc
54
Libraries/Components/StaticContainer.js
Normal file
54
Libraries/Components/StaticContainer.js
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @generated SignedSource<<2a163cdb088fb963f941e627fd89ce11>>
|
||||
*
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* !! This file is a check-in of a static_upstream project! !!
|
||||
* !! !!
|
||||
* !! You should not modify this file directly. Instead: !!
|
||||
* !! 1) Use `fjs use-upstream` to temporarily replace this with !!
|
||||
* !! the latest version from upstream. !!
|
||||
* !! 2) Make your changes, test them, etc. !!
|
||||
* !! 3) Use `fjs push-upstream` to copy your changes back to !!
|
||||
* !! static_upstream. !!
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*
|
||||
* Copyright 2004-present Facebook. All Rights Reserved.
|
||||
*
|
||||
* @providesModule StaticContainer.react
|
||||
* @typechecks
|
||||
* @flow
|
||||
*/
|
||||
|
||||
var React = require('React');
|
||||
|
||||
var onlyChild = require('onlyChild');
|
||||
|
||||
/**
|
||||
* Renders static content efficiently by allowing React to short-circuit the
|
||||
* reconciliation process. This component should be used when you know that a
|
||||
* subtree of components will never need to be updated.
|
||||
*
|
||||
* var someValue = ...; // We know for certain this value will never change.
|
||||
* return (
|
||||
* <StaticContainer>
|
||||
* <MyComponent value={someValue} />
|
||||
* </StaticContainer>
|
||||
* );
|
||||
*
|
||||
* Typically, you will not need to use this component and should opt for normal
|
||||
* React reconciliation.
|
||||
*/
|
||||
class StaticContainer extends React.Component {
|
||||
|
||||
shouldComponentUpdate(nextProps: Object): boolean {
|
||||
return !!nextProps.shouldUpdate;
|
||||
}
|
||||
|
||||
render() {
|
||||
var child = this.props.children;
|
||||
return (child === null || child === false) ? null : onlyChild(child);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = StaticContainer;
|
||||
Reference in New Issue
Block a user