React Native Console v2021.3.2 发布, 支持JSX大纲显示

今天, 发布了 React Native Console v2021.3.2 版本. 很久以来, WebStorm Structure 视图中只有JavaScript变量而没有JSX相关的内容, 这点对 React 开发者来说一直很不友好. 此版本弥补了这个空白.

更新内容

  • JSX 大纲视图, 支持 React Native 或 React 应用 (需要运行于 WebStorm 或 IDEA Ultimate), 支持 TypeScript 和 ECMAScript 6 / Flow.

  • 支持代码和大纲树节点的双向联动显示.

  • 支持大纲选中高亮JSX标签内的代码.

  • 大纲支持快速搜索, 按下字母即可开始实时搜索

A screenshot of Notes v2021.3.3
RN 助手 v2021.3.3

下载地址

Jetbrains Marketplace Downloads

效果展示

TypeScript 示例
import React, {Component, ReactNode} from 'react';
import './App.css';

export class HomePage extends Component {
    hello(): ReactNode {
        let a = true;
        if (a && false) {
            return <div>
                <p></p>
            </div>;
        }
        return;
    }
}

function outside() {
    let a = true;
    if (a && false) {
        return <div></div>;
    }
    return <p></p>;
}

class ABC {

    helloWorld3() {
        let a = true;
        if (a && false) {
            return <div></div>;
        }
        return <p></p>;
    }
}

image

普通React Native App 代码示例
/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow strict-local
 */

import React from 'react';
import type {Node} from 'react';
import {
  Alert,
  Pressable,
  SafeAreaView,
  ScrollView,
  StatusBar,
  StyleSheet,
  Text,
  useColorScheme,
  View,
} from 'react-native';

import {
  Colors,
  DebugInstructions,
  Header,
  LearnMoreLinks,
  ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';

const Section = ({children, title}): Node => {
  const isDarkMode = useColorScheme() === 'dark';
  return (
    <View style={styles.sectionContainer}>
      <Text
        style={[
          styles.sectionTitle,
          {
            color: isDarkMode ? Colors.white : Colors.black,
          },
        ]}>
        {title}
      </Text>
      <Pressable onPress={ () => Alert.alert(
          "Alert Title",
          "My Alert Msg",
          [
            {
              text: "Cancel",
              onPress: () => console.log("Cancel Pressed"),
              style: "cancel"
            },
            { text: "OK", onPress: () => console.log("OK Pressed") }
          ]
      )} >
        <Text>I'm pressable!</Text>
      </Pressable>
      <Text
        style={[
          styles.sectionDescription,
          {
            color: isDarkMode ? Colors.light : Colors.dark,
          },
        ]}>
        {children}
      </Text>
    </View>
  );
};

const App: () => Node = () => {
  const isDarkMode = useColorScheme() === 'dark';

  const backgroundStyle = {
    backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
  };

  return (
    <SafeAreaView style={backgroundStyle}>
      <StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
      <ScrollView
        contentInsetAdjustmentBehavior="automatic"
        style={backgroundStyle}>
        <Header />
        <View
          style={{
            backgroundColor: isDarkMode ? Colors.black : Colors.white,
          }}>
          <Section title="Step One">
            Edit <Text style={styles.highlight}>App.js</Text> to change this
            screen and then come back to see your edits.
          </Section>
          <Section title="See Your Changes">
            <ReloadInstructions />
          </Section>
          <Section title="Debug">
            <DebugInstructions />
          </Section>
          <Section title="Learn More">
            Read the docs to discover what to do next:
          </Section>
          <LearnMoreLinks />
        </View>
      </ScrollView>
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  sectionContainer: {
    marginTop: 32,
    paddingHorizontal: 24,
  },
  sectionTitle: {
    fontSize: 24,
    fontWeight: '600',
  },
  sectionDescription: {
    marginTop: 8,
    fontSize: 18,
    fontWeight: '400',
  },
  highlight: {
    fontWeight: '700',
  },
});

export default App;

image

一个真实的React Native 项目的大纲展示:
image

posted @ 2022-01-27 14:21  beansoft  阅读(173)  评论(0编辑  收藏  举报