-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RNMobile][Monorepo] Make the native app customizable by a parent app #21332
Merged
hypest
merged 52 commits into
feat/import-gutenberg-mobile-no-squash
from
rnmobile/experiment-monorepo-new-setup
Jun 17, 2020
Merged
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
2541642
Experiment a new way to setup the native editor that can be customize…
Tug c252eb3
Add mock for render
Tug 0a61a22
Add other properties to @wordpress/element mock implementation
Tug b63829e
Merge remote-tracking branch 'origin/feat/import-gutenberg-mobile-no-…
Tug 318e668
prettier changes
Tug 3c9d92e
Split block_editor_props action in 2 depending if we're receiving pro…
Tug 2cfee15
Refactor initializeEditor and init props
Tug 5c34df8
Do not record screen for Android on non-macos platforms
ceyhun ce9e145
Fix building wpandroid
Tug da6949a
Update android deviceName for remote e2e tests
ceyhun 52ef860
Update react-native-get-random-values in bridge build
Tug c910d8d
Update formatting
Tug 67b39a7
Update bridge build config for android
Tug 688b42e
Revert linking react-native-get-random-values manually for ios
Tug e5186c5
Update package-lock.json with changes from running npm install
ceyhun 0dfffe0
Fix linter error
ceyhun 75260fc
Remove Podfile change
ceyhun 16d8a00
Fix android demo app blank screen when building with __DEV__ flag bei…
ceyhun 14c9a95
Fix native unit tests
ceyhun af9a8f4
Remove third-party-podspecs from react-native-bridge
ceyhun 3e153c2
Commit hermes locally so we can build gutenberg using jitpack without…
Tug 580130f
Remove hermes headers
Tug c5e9385
Update github actions/cache to v2
ceyhun 3466d25
Only run gallery e2e tests
ceyhun 0f7f14a
Try different jest config
ceyhun ddc7209
Try different jest config
ceyhun 823d9bd
Add logs
ceyhun c724716
Revert "Add logs"
ceyhun f684dc3
Add log
ceyhun 3c8056c
Revert "Add log"
ceyhun cc0c972
Add package-lock.json changes after npm install
ceyhun 85ba21b
Force exit jest after all tests have completed running
ceyhun 7a96fc7
Update podfile.lock
Tug f621b57
Update .gitignore
Tug 37c76c4
Update bridge build
Tug 9fbc93d
Fix link error in react-native-bridge/package.json
Tug e7961e1
Fix react-native entry in @wordpress/react-native-bridge package.json
Tug 1944d87
Remove unused commands and update clean commands
Tug 9e28af9
Add RNGetRandomValuesPackage to WPAndroid glue code
ceyhun a530091
Update working directory for npm related bridge commands
ceyhun 6912528
Decrease sleep time for android recording process
ceyhun cc6d046
Disable npm cache for android and ios runners
ceyhun 1f5c191
Re-enable npm cache but use exact key for restore
ceyhun 1711205
Update package-lock.json by re-adding react-native-editor to bust npm…
ceyhun dd076a9
Remove nvm step from iOS runner
ceyhun e5329b4
Decrease sleep time for android recording process
ceyhun 8832f53
Ignore and log android screen recording errors
ceyhun b46844e
Remove unnecessary patch files
Tug f71b3ab
Try setting max worker to 2 to avoid error 137 on circle CI
Tug 9113661
Updated commands in README.md
cameronvoell a79e21a
Use Xcode version 11.4.1 when running e2e tests
ceyhun 66c0dc7
Update package-lock.json
ceyhun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,39 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { AppRegistry } from 'react-native'; | ||
import { omit } from 'lodash'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { applyFilters, doAction } from '@wordpress/hooks'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { cloneElement } from './react'; | ||
|
||
const render = ( element, id ) => | ||
AppRegistry.registerComponent( id, () => ( propsFromParent ) => { | ||
const parentProps = omit( propsFromParent || {}, [ 'rootTag' ] ); | ||
|
||
doAction( 'native.pre-render', parentProps ); | ||
|
||
const filteredProps = applyFilters( | ||
'native.block_editor_props', | ||
parentProps | ||
); | ||
|
||
doAction( 'native.render', filteredProps ); | ||
|
||
return cloneElement( element, filteredProps ); | ||
} ); | ||
|
||
/** | ||
* Render a given element on Native. | ||
* This actually returns a componentProvider that can be registered with `AppRegistry.registerComponent` | ||
* | ||
* @param {WPElement} element Element to render. | ||
*/ | ||
export { render }; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why not to execute all this logic inside initializeEditor in the @wordpress/edit-post package?
Overriding React methods and adding WP hooks might have some performance implications but I guess it’s called only once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's to be able to customize the editor from an outside package. In this case a repo that's importing Gutenberg as a submodule. Correct me if I'm wrong @Tug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No we could totally have this logic in
@wordpress/edit-post
(or in@wordpress/react-native-editor
as it was the case in the monorepo branch before this PR).The idea here is simply to get closer to having
@wordpress/edit-post
work as cross-platform package. If you look atedit-post/src/index.native.js
you'll see that the init code is much closer to the web one now.
We're not overriding anything though, the
render
function wasn't defined for native prior to this. And yes it's only rendered once on load.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It probably doesn't matter as much then now, but I guess
initializeEditor
would be the best place to run all those side effects.