Plan: New Hermes/RNV8 debugger support #774
Replies: 16 comments 30 replies
-
Thanks for working on this. This apparently works with a bare React Native app: https://github.com/gusgard/react-native-devsettings but I have not been able to get it working with Expo in managed workflow. Which is a pretty large portion of people building with react-native. |
Beta Was this translation helpful? Give feedback.
-
any progress? |
Beta Was this translation helpful? Give feedback.
This comment has been minimized.
This comment has been minimized.
-
Maybe this is useful: if (DEV) { |
Beta Was this translation helpful? Give feedback.
-
Hi jhen0409, I hope you're doing well! How is it going? |
Beta Was this translation helpful? Give feedback.
-
Ahoy, For anyone who got frustrated with Hermes and the JS debugger in a React-Native app (I use Expo), here is a quick alternative solution for logging out Redux States (I use Redux Toolkit) while we are waiting for actual dev-friendly tools, I use lodash in my project: const additionalMiddlewaresInDevMode = __DEV__ ? [stateChangeLogger] : [];
const store = configureStore({
reducer: persistedReducer,
devTools: false,
middleware: [saga, ...additionalMiddlewaresInDevMode],
}); import { isEqual } from 'lodash';
import { AnyAction, Dispatch, Middleware, MiddlewareAPI } from 'redux';
/**
* Logs the differences between two states
* This function recursively compares two objects and logs the differences between them.
*
* @param prevState - The previous state
* @param nextState - The next state
*/
function logStateDifferences(prevState: any, nextState: any) {
const differences: { [key: string]: any } = {};
// Recursively compare objects for differences
const compareObjects = (prev: any, next: any, path: string) => {
Object.keys(next).forEach((key) => {
const currentPath = path ? `${path}.${key}` : key;
// Check if the key exists in the previous state
if (!(key in prev)) {
differences[currentPath] = {
a_prev: undefined,
b_next: next[key],
};
}
// Check if the values are different
else if (!isEqual(prev[key], next[key])) {
// If the values are objects, recursively compare them
if (typeof prev[key] === 'object' && typeof next[key] === 'object') {
compareObjects(prev[key], next[key], currentPath);
} else {
differences[currentPath] = {
a_prev: prev[key],
b_next: next[key],
};
}
}
});
};
compareObjects(prevState, nextState, '');
if (Object.keys(differences).length > 0) {
console.table(differences);
} else {
console.log('%cNo State Differences', 'color: cyan');
}
}
/**
* Logs the state before and after the dispatch
* Use this middleware to log the state before and after the dispatch until we get an actually
* working Redux Devtools for React-native with Hermes as the JS engine.
*
* It groups the logs by the action type and logs the state before and after the dispatch.
* If the states are identical, it logs that they are identical.
*
* @param api - The redux middleware API
*/
const stateChangeLogger: Middleware = (api: MiddlewareAPI) => (next: Dispatch<AnyAction>) => (action: AnyAction) => {
const previousState = api.getState();
const result = next(action);
const afterState = api.getState();
console.groupCollapsed(`%cAction Dispatched: ${action.type}`, 'color: yellow');
console.log('%cState Before Dispatch:', 'color: orange', previousState);
console.log('%cAction:', 'color: yellow', action);
console.log('%cState After Dispatch:', 'color: orange', afterState);
if (isEqual(previousState, afterState)) {
console.log('%cStates are identical', 'color: cyan');
} else {
console.groupCollapsed('%cState Differences:', 'color: cyan');
logStateDifferences(previousState, afterState);
console.groupEnd();
}
console.groupEnd();
return result; // Return the result of the action dispatch
};
export default stateChangeLogger; |
Beta Was this translation helpful? Give feedback.
-
@jhen0409 Any progress on this? |
Beta Was this translation helpful? Give feedback.
-
For anyone on Expo trying to get Redux DevTools to work, there's a temporary solution using a plugin. See here |
Beta Was this translation helpful? Give feedback.
-
Is anyone interested in making a front end for @istvan-panczel's hook? Instead of console.logging the diff-ed redux state, it's sent to an observing front end app that makes it look all pretty like react-native-debugger? |
Beta Was this translation helpful? Give feedback.
-
Since I updated to Expo 50, I have had this problem: if I reload the app while the dev-tools is running, the app crashes on the simulator (as in quits and I have to relaunch it). It only started happening since Expo 50 but it's been a while since I updated and still having the same problem. Is anyone else having this issue? |
Beta Was this translation helpful? Give feedback.
-
I guess this project is dead in the water, if it can't support Hermes, and there are not updates about it. Too bad, I used it all the time. |
Beta Was this translation helpful? Give feedback.
-
Any update guys? |
Beta Was this translation helpful? Give feedback.
-
For those who miss Redux DevTools for time-travel debugging and live editing, I’ve managed to make it work for React Native with the Hermes engine. Checkout my repo: https://github.com/aliffazfar/redux-devtools The only thing we miss is the network inspector in Chrome, like in the old days. However, we can move on with Reactotron, which works really great for debugging the network, AsyncStorage, and logs. I have tested and can confirm that RocketSim also work great with React Native to inspect the network. Check this out: https://x.com/AliffAzfar/status/1814121783303569838 |
Beta Was this translation helpful? Give feedback.
-
I just want my redux debug tools back. Bring em baack please 😭 |
Beta Was this translation helpful? Give feedback.
-
We should really add https://github.com/gusgard/react-native-devsettings to the readme. |
Beta Was this translation helpful? Give feedback.
-
Related: #573
I'm started experimenting with support for Hermes debugger (it also works on RNV8) on RNDebugger. The main purpose is we can keep the same debug experience with this tool.
Until recently I started using JSI and planning to support new architecture in my projects. Flipper is awesome tool to help me debug more deeper issues, but it have some performance issue in my use cases, I wish we had something more lightweight & out-of-the-box tool like RNDebugger.
I'll start the related work at August, these are some key support items:
DevTools
Enable open in editor in console (docs/enable-open-in-editor-in-console.md)
Console REPL
Network tab
React / Redux (remotedev) / Apollo Client DevTools support
Storage
The initial version of new debugger implementation will be included in v0.15. Before this, I'll upgrade dependencies & fix some small issues for "old" remote debugger in v0.14.
I'm currently only spending 10~20% of my workday doing it, so any help or advice would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions