Vue to React Component Transformer CLI

1.0.0 · abandoned · verified Sun Apr 19

The `vue-to-react` package is a command-line interface (CLI) tool designed to transform Vue components, including both JSX and Single File Components (SFCs), into React components. It aims to assist developers in migrating existing Vue.js codebases to React by automating the conversion of component structure and partial logic. The package reached its 1.0.0 version but development appears to have ceased around 2018, indicating an abandoned status rather than active development. Key differentiators included its attempt to support both Vue JSX and SFCs, and its mapping of a limited set of Vue lifecycle methods to their React equivalents. However, it has significant limitations, explicitly stating it does not support advanced Vue features like object/array syntax for class/style bindings, `watch` or `components` props for JSX components, custom directives, filter expressions, and certain `v-bind`/`v-on` shorthands. Its utility is thus restricted to very simple component structures.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates the global installation of the `vue-to-react` CLI tool and how to use it to transform a basic Vue Single File Component (`.vue` file) into a React component, specifying input, output directory, and file name.

// Example Vue SFC (input.vue) for transformation
// <template>
//   <div v-if="isVisible" v-bind:class="classes" v-on:click="handleClick">
//     Hello, {{ name }}!
//     <p v-text="message"></p>
//   </div>
// </template>
// <script>
// export default {
//   props: ['name'],
//   data() {
//     return {
//       message: 'Welcome to Vue.',
//       isActive: true,
//       hasError: false
//     };
//   },
//   computed: {
//     classes() {
//       return { active: this.isActive, 'text-danger': this.hasError };
//     },
//     isVisible() {
//       return this.name === 'World';
//     }
//   },
//   methods: {
//     handleClick() {
//       console.log('Clicked!');
//     }
//   },
//   mounted() {
//     console.log('Vue component mounted.');
//   }
// }
// </script>
// <style scoped>
// .active { color: blue; }
// .text-danger { color: red; }
// </style>

// To run the transformation:
// 1. Save the above Vue component content as `input.vue` in your project root.
// 2. Install the tool globally:
//    npm install -g vue-to-react
// 3. Run the transformation command:
//    vtr -i input.vue -o ./output -n ReactComponent
//
// This will create 'output/ReactComponent.js' which is the transformed React component.

view raw JSON →