Giter VIP home page Giter VIP logo

babel-plugin-jsx-vue-functional's Introduction

babel-plugin-jsx-vue-functional's People

Contributors

nickmessing avatar niksy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

niksy egoist-bot

babel-plugin-jsx-vue-functional's Issues

What do you mean by this won't work in 2.0 in Readme

I'm a little confused by the example you gave that won't work down below

This plugin will transform all named arrow functions that contain JSX and starting with version 2.0.0 so this code will not work:

const A = () => <h1>Hello World</h1> export const B = ({ props, listeners }) => <div onClick={listeners.click}>{props.msg}{A()}</div>

Can you please explain, what would work rather as the example above this section is same as well.

Allow to pass props as first argument

TypeScript supposes first argument of functional component is props.

https://www.typescriptlang.org/docs/handbook/jsx.html#stateless-functional-component

It would be nice if some option will be added that treats first argument as props.

Example:

const A = (props: { msg: string }, { listeners }) => <div onClick={listeners.click}>{props.msg}</div>;

will be transpiled into

const A = {
  functional: true,
  render: (h, ctx) => (
    (props, { listeners }) => <div onClick={listeners.click}>{props.msg}</div>
  )(ctx.props, ctx)
}

Transpiling non-exported functions?

Documentation says:

This plugin will transform all named exported arrow functions that contain JSX.

What about non-exported functions, e.g. small components defined in same file as larger component? Do you think this makes sense for transpiling, or transpiler can encounter problems with false positives?

Error installing

Machine windows 10
node version 8.12
npm - 6.4.1

Command - npm i -D babel-plugin-jsx-vue-functional on git bash

Error -

code ENOENT npm ERR! errno -4058 npm ERR! syscall rename npm ERR! enoent ENOENT: no such file or directory, rename 'E:\Projects\vue_deep_dive\node_modules\babel-plugin-jsx-vue-functional' -> 'E:\Projects\vue_deep_dive\node_modules\.babel-plugin-jsx-vue-functional.DELETE' npm ERR! enoent This is related to npm not being able to find a file.

Option to add "name" property

Adding name property could help in debugging your application. This could be defined as option for plugin so it isn’t active by default.

What do you think?

How to use, newbie at functional components

I'm a total newbie at jsx functional components. Hopefully you can provide an example of how to use them. I don't understand what's on the readme and articles such as:

https://alligator.io/vuejs/render-functional-components/

Aren't that helpful for a beginner like me. I'm able to understand "babel-plugin-transform-vue-jsx" ok, but this topic eludes me right now.

From my example I keep on getting "draggableItems is not a function". Although I can console.log it and I see the object just fine. But I'm struggling to make it work.

Here's a quick example:

export default function(h, index, itemsLength) {
	const draggableItems = (index, itemsLength) => {
		let dragControls = [];
		let draggableClass = "...";

		if (index == 0) {
			draggableClass += " right";
			dragControls.push(draggableClass);
		} else if (index < (itemsLength - 1)) {
			draggableClass += " left";
			dragControls.push(draggableClass);
		} else {
			draggableClass += " right";
			dragControls.push(draggableClass);

			draggableClass += " left";
			dragControls.push(draggableClass);
		}		

		const items = dragControls.map((draggableClass) => {
			return <div class={draggableClass}>
				[ ... stuf here ...]
			</div>
		});

		return { items }		
	}	

	return draggableItems(index, itemsLength);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.