forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make ScrollView StrictMode compatible
Converts ScrollView to use constructor instead of UNSAFE_componentWillMount and componentDidUpdate instead of UNSAFE_componentWillReceiveProps. Related to facebook#22186
- Loading branch information
Showing
5 changed files
with
76 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @flow | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const React = require('react'); | ||
const {StrictMode} = React; | ||
const ReactNative = require('react-native'); | ||
const {ScrollView, Text} = ReactNative; | ||
|
||
type Props = $ReadOnly<{||}>; | ||
type State = {|result: string|}; | ||
|
||
const componentsToTest = [ScrollView]; | ||
|
||
class StrictModeExample extends React.Component<Props, State> { | ||
render() { | ||
return ( | ||
<StrictMode> | ||
{componentsToTest.map(Component => ( | ||
<Component key={Component.displayName}> | ||
<Text>{Component.displayName}</Text> | ||
</Component> | ||
))} | ||
</StrictMode> | ||
); | ||
} | ||
} | ||
|
||
exports.framework = 'React'; | ||
exports.title = 'StrictMode'; | ||
exports.description = 'See components in strict mode.'; | ||
exports.examples = [ | ||
{ | ||
title: 'Strict Mode', | ||
render() { | ||
return <StrictModeExample />; | ||
}, | ||
}, | ||
]; |