-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
[react devtools] Device storage support #25452
Merged
Merged
Conversation
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
rbalicki2
force-pushed
the
device-storage-devtools
branch
4 times, most recently
from
October 8, 2022 23:58
b66ca95
to
9bf1b6c
Compare
@lunaruan This is basically the same as the previous (approved) PR. I just had to recreate it, because I deleted my fork and recreated my fork, and can no longer amend that PR. The difference is that |
rbalicki2
force-pushed
the
device-storage-devtools
branch
from
October 9, 2022 00:07
9bf1b6c
to
7a8160e
Compare
This was referenced Oct 9, 2022
rbalicki2
force-pushed
the
device-storage-devtools
branch
from
October 19, 2022 11:48
7a8160e
to
b134b99
Compare
rbalicki2
force-pushed
the
device-storage-devtools
branch
from
October 19, 2022 12:22
b134b99
to
f053aac
Compare
rickhanlonii
pushed a commit
that referenced
this pull request
Dec 3, 2022
# Summary * This PR adds support for persisting certain settings to device storage, allowing e.g. RN apps to properly patch the console when restarted. * The device storage APIs have signature `getConsolePatchSettings()` and `setConsolePatchSettings(string)`, in iOS, are thin wrappers around the `Library/Settings` turbomodule, and wrap a new TM that uses the `SharedPreferences` class in Android. * Pass device storage getters/setters from RN to DevTools' `connectToDevtools`. The setters are then used to populate values on `window`. Later, the console is patched using these values. * If we receive a notification from DevTools that the console patching fields have been updated, we write values back to local storage. * See facebook/react-native#34903 # How did you test this change? Manual testing, `yarn run test-build-devtools`, `yarn run prettier`, `yarn run flow dom` ## Manual testing setup: ### React DevTools Frontend * Get the DevTools frontend in flipper: * `nvm install -g react-devtools-core`, then replace that package with a symlink to the local package * enable "use globally installed devtools" in flipper * yarn run start in react-devtools, etc. as well ### React DevTools Backend * `yarn run build:backend` in react-devtools-core, then copy-paste that file to the expo app's node_modules directory ### React Native * A local version of React Native can be patched in by modifying an expo app's package.json, as in `"react-native": "rbalicki2/react-native#branch-name"` # Versioning safety * There are three versioned modules to worry about: react native, the devtools frontend and the devtools backend. * The react devtools backend checks for whether a `cachedSettingsStore` is passed from react native. If not (e.g. if React Native is outdated), then no behavior changes. * The devtools backend reads the patched console values from the cached settings store. However, if nothing has been stored, for example because the frontend is outdated or has never synced its settings, then behavior doesn't change. * The devtools frontend sends no new messages. However, if it did send a new message (e.g. "store this value at this key"), and the backend was outdated, that message would be silently ignored.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
getValue(string)
andsetValue(string, string)
, and are thin wrappers around theLibrary/Settings
turbomodule.connectToDevtools
. The setters are then used to populate values onwindow
. Later, the console is patched using these values.connectToDevTools
react-native#34903How did you test this change?
Manual testing,
yarn run test-build-devtools
,yarn run prettier
,yarn run flow dom
Manual testing setup:
React DevTools Frontend
nvm install -g react-devtools-core
, then replace that package with a symlink to the local packageReact DevTools Backend
yarn run build:backend
in react-devtools-core, then copy-paste that file to the expo app's node_modules directoryReact Native
"react-native": "rbalicki2/react-native#branch-name"
Versioning safety
cachedSettingsStore
is passed from react native. If not (e.g. if React Native is outdated), then no behavior changes.