LogBox: Intelligently Un-Collapse Stack Frames

Summary:
Tweaks LogBox so that if all stack frames are collapsed, start off without collapsing any of them.

It saves developers from one extra interaction to make the LogBox actually useful for errors where every frame is ignored.

Changelog:
[General][Changed] - LogBox will not initially collapse stack frames if every frame would be collapsed.

Differential Revision: D26266195

fbshipit-source-id: dcdbe0834da5fc3a0bf49fb7857de30dd7e4b8cb
This commit is contained in:
Tim Yung 2021-02-08 17:15:23 -08:00 коммит произвёл Facebook GitHub Bot
Родитель 7f5ec15009
Коммит 88a41f180c
1 изменённых файлов: 4 добавлений и 1 удалений

Просмотреть файл

@ -63,7 +63,10 @@ export function getCollapseMessage(
}
function LogBoxInspectorStackFrames(props: Props): React.Node {
const [collapsed, setCollapsed] = React.useState(true);
const [collapsed, setCollapsed] = React.useState(() => {
// Only collapse frames initially if some frames are not collapsed.
return props.log.getAvailableStack().some(({collapse}) => !collapse);
});
function getStackList() {
if (collapsed === true) {