A framework for building native macOS apps with React.
Перейти к файлу
Samuel Susla 5fa6c5a941 Enable modernize-pass-by-value clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-pass-by-value.html

# Isn't it wasteful to copy? Isn't reference more efficient?

This rule of thumb is no longer true since C++11 with move semantics. Let's look at some examples.

# Option one

```
class TextHolder
{
public:
   TextBox(std::string const &text) : text_(text) {}
private:
   std::string text_;
};
```

By using reference here, we prevent the caller from using rvalue to and avoiding copy. Regardless of what the caller passes in, copy always happens.

# Option two

```
class TextHolder
{
public:
   TextBox(std::string const &text) : text_(text) {}
   TextBox(std::string &&text) : text_(std::move(text)) {}
private:
   std::string text_;
};
```
Here, we provide two constructors, one for const reference and one for rvalue reference. This gives the caller option to avoid copy. But now we have two constructors, which is not ideal.

# Option three (what we do in this diff)

```
class TextHolder
{
public:
   TextBox(std::string text) : text_(std::move(text)) {}
private:
   std::string text_;
};
```
Here, the caller has option to avoid copy and we only have single constructor.

Reviewed By: fkgozali, JoshuaGross

Differential Revision: D33276841

fbshipit-source-id: 619d5123d2e28937b22874650366629f24f20a63
2021-12-23 07:53:48 -08:00
.bundle Introduce Gemfile, ruby-version (#32303) 2021-10-01 21:22:26 -07:00
.circleci Update bump-oss-version.js to guide releaser through release actions (#32769) 2021-12-17 18:37:38 -08:00
.github chore: use npx to run react-native (#32788) 2021-12-20 10:51:11 -08:00
IntegrationTests RN: Resolve Outstanding ESLint Warnings 2021-11-09 21:46:21 -08:00
Libraries Enable ConcurrentRoot in RN VR apps 2021-12-22 03:00:45 -08:00
React C++ - better => butter 2021-12-20 22:25:14 -08:00
ReactAndroid Refactor duplicated code in ReactRootView 2021-12-22 02:57:56 -08:00
ReactCommon Enable modernize-pass-by-value clang tidy rule 2021-12-23 07:53:48 -08:00
bots Remove warning against PR for release branch 2021-12-02 12:11:52 -08:00
docs Generate doc info for RN components 2019-09-19 18:36:25 -07:00
flow Inherit type of queueMicrotask from Flow 2021-10-19 11:30:58 -07:00
flow-typed/npm RN: Add `glob` Flow Definition 2021-10-20 19:25:45 -07:00
gradle/wrapper bump gradle to 7.3 (#32588) 2021-11-15 06:47:39 -08:00
jest RN: Eliminate Jest Log Spew 2021-11-09 23:42:28 -08:00
keystores Use fb_native_wrapper for all targets 2018-10-31 11:47:42 -07:00
local-cli Update references to the CLI (#23052) 2019-01-21 09:13:08 -08:00
packages Fix remaining CircleCI eslint warnings 2021-12-21 12:34:28 -08:00
repo-config Update bump-oss-version.js to guide releaser through release actions (#32769) 2021-12-17 18:37:38 -08:00
scripts Clean up: remove eslint-disable no-undef in test_js* scripts 2021-12-21 11:49:40 -08:00
template Setup a `newArchEnabled` property to Opt-in the New Architecture in the template (#32790) 2021-12-21 11:20:19 -08:00
third-party-podspecs Remove libstdc++ dependency (#32247) 2021-10-08 14:16:54 -07:00
tools/build_defs introduce get_rn_ios_target_sdk_version() 2021-12-09 04:08:41 -08:00
.buckconfig Bump Buck compile SDK Android version to 31 2021-11-26 09:40:54 -08:00
.buckjavaargs limiting BUCK's memory for CI 2016-02-01 10:49:33 -08:00
.clang-format Moving ObjC specific clang-format rules to the common config 2019-02-11 13:07:09 -08:00
.editorconfig Revert removal of CRLF from Windows bat files (#31398) 2021-09-09 22:44:32 -07:00
.eslintignore Lint: fix few "no-unused-var" warnings for imports (#30157) 2020-10-26 17:19:14 -07:00
.eslintrc Rename eslint-plugin-codegen to eslint-plugin-specs (#32698) 2021-12-02 20:47:12 -08:00
.flowconfig Deploy 0.168.0 to xplat 2021-12-17 14:58:51 -08:00
.flowconfig.android Deploy 0.168.0 to xplat 2021-12-17 14:58:51 -08:00
.gitignore Add /template/ios/build/ to gitignore 2021-12-13 10:49:00 -08:00
.prettierrc JS: Upgrade to Prettier v2.4.1 [1/n] 2021-11-02 22:14:16 -07:00
.ruby-version Introduce Gemfile, ruby-version (#32303) 2021-10-01 21:22:26 -07:00
BUCK introduce get_rn_ios_target_sdk_version() 2021-12-09 04:08:41 -08:00
CHANGELOG.md add 0.66.4 changelog (#32733) 2021-12-10 10:18:52 -08:00
CODE_OF_CONDUCT.md docs: add new version convenant contribuitor guide link (#32107) 2021-08-30 10:18:11 -07:00
CONTRIBUTING.md fix: Updated releases/changelog links (#32551) 2021-11-08 09:25:47 -08:00
ECOSYSTEM.md docs: fix url for chainreactconf (#30199) 2020-10-19 07:35:37 -07:00
Gemfile Introduce Gemfile, ruby-version (#32303) 2021-10-01 21:22:26 -07:00
Gemfile.lock iOS Ruby Updates (#32456) 2021-10-21 15:58:18 -07:00
LICENSE Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
LICENSE-docs More licenses 2015-03-24 19:59:10 -07:00
README.md fix: Updated releases/changelog links (#32551) 2021-11-08 09:25:47 -08:00
React-Core.podspec Fix the default template when RCT_NEW_ARCH_ENABLE=1 (#32775) 2021-12-16 15:10:49 -08:00
React.podspec Resolve "fatal: not a git repository" error outside of git repositories 2021-04-15 13:30:31 -07:00
build.gradle.kts Create a `cleanAll` Top Level Gradle task. 2021-11-30 01:53:06 -08:00
cli.js Show full price instead of monthly price within the lead form 2019-03-28 16:07:19 -07:00
gradle.properties Make the `reactNativeArchitectures` property more discoverable 2021-11-08 07:21:08 -08:00
gradlew bump gradle to 7.3 (#32588) 2021-11-15 06:47:39 -08:00
gradlew.bat Re-sync with internal repository (#32212) 2021-09-15 10:45:06 +01:00
index.js RN: Deprecate Prop Types 2021-10-21 17:45:47 -07:00
interface.js restore core lib Flow definitions for Request, Response, etc. 2021-01-06 17:24:51 -08:00
jest-preset.js Create `@react-native/polyfills` package. 2020-07-22 03:02:45 -07:00
jest.config.js RN: Remove `fbjs` Dependency 2020-08-28 12:16:26 -07:00
metro.config.js Use newer metro language: `blacklistRE` -> `blockList` (#30342) 2021-10-05 02:26:26 -07:00
package.json Deploy 0.168.0 to xplat 2021-12-17 14:58:51 -08:00
react-native.config.js Migrating RNTester to Packages Directory (#29567) 2020-08-19 17:57:08 -07:00
react.gradle Static link for hermes-inspector (#32694) 2021-12-13 07:48:39 -08:00
rn-get-polyfills.js Create `@react-native/polyfills` package. 2020-07-22 03:02:45 -07:00
runXcodeTests.sh Migrating RNTester to Packages Directory (#29567) 2020-08-19 17:57:08 -07:00
settings.gradle.kts Setup a `newArchEnabled` property to Opt-in the New Architecture in the template (#32790) 2021-12-21 11:20:19 -08:00
template.config.js imp: Add titlePlaceholder in template.config.js (#26218) 2020-05-12 09:09:23 -07:00
yarn.lock Update bump-oss-version.js to guide releaser through release actions (#32769) 2021-12-17 18:37:38 -08:00

README.md

React Native

Learn once, write anywhere:
Build mobile apps with React.

React Native is released under the MIT license. Current CircleCI build status. Current npm package version. PRs welcome! Follow @reactnative

Getting Started · Learn the Basics · Showcase · Contribute · Community · Support

React Native brings React's declarative UI framework to iOS and Android. With React Native, you use native UI controls and have full access to the native platform.

  • Declarative. React makes it painless to create interactive UIs. Declarative views make your code more predictable and easier to debug.
  • Component-Based. Build encapsulated components that manage their state, then compose them to make complex UIs.
  • Developer Velocity. See local changes in seconds. Changes to JavaScript code can be live reloaded without rebuilding the native app.
  • Portability. Reuse code across iOS, Android, and other platforms.

React Native is developed and supported by many companies and individual core contributors. Find out more in our ecosystem overview.

Contents

📋 Requirements

React Native apps may target iOS 11.0 and Android 5.0 (API 21) or newer. You may use Windows, macOS, or Linux as your development operating system, though building and running iOS apps is limited to macOS. Tools like Expo can be used to work around this.

🎉 Building your first React Native app

Follow the Getting Started guide. The recommended way to install React Native depends on your project. Here you can find short guides for the most common scenarios:

📖 Documentation

The full documentation for React Native can be found on our website.

The React Native documentation discusses components, APIs, and topics that are specific to React Native. For further documentation on the React API that is shared between React Native and React DOM, refer to the React documentation.

The source for the React Native documentation and website is hosted on a separate repo, @facebook/react-native-website.

🚀 Upgrading

Upgrading to new versions of React Native may give you access to more APIs, views, developer tools, and other goodies. See the Upgrading Guide for instructions.

React Native releases are discussed in this discussion repo.

👏 How to Contribute

The main purpose of this repository is to continue evolving React Native core. We want to make contributing to this project as easy and transparent as possible, and we are grateful to the community for contributing bug fixes and improvements. Read below to learn how you can take part in improving React Native.

Code of Conduct

Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.

Contributing Guide

Read our Contributing Guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to React Native.

Open Source Roadmap

You can learn more about our vision for React Native in the Roadmap.

Good First Issues

We have a list of good first issues that contain bugs which have a relatively limited scope. This is a great place to get started, gain experience, and get familiar with our contribution process.

Discussions

Larger discussions and proposals are discussed in @react-native-community/discussions-and-proposals.

📄 License

React Native is MIT licensed, as found in the LICENSE file.

React Native documentation is Creative Commons licensed, as found in the LICENSE-docs file.