Giter VIP home page Giter VIP logo

Comments (3)

zacacollier avatar zacacollier commented on April 27, 2024 10

I'm also experiencing this problem.

In this view, the spread operator works as expected:

import Posts from 'components/Posts'
import Profile from 'components/Profile'
import posts from '../../posts'

export default {
  name: 'Home',
  render (h) {
    // Set props to be passed here
    const data = {
      props: {
        posts: posts,
        msg: 'hola'
      }
    }
    return (
      <div class='page'>
        <Profile />
        <Posts {...data} />
      </div>
    )
  }
}

Then, in the child component Posts, I have to explicitly set props:

import Post from '../Post'

export default {
  name: 'Posts',
  props: {
    posts: Array,
    msg: String
  },
  render (h) {
    const data = {
      posts: this.posts
    }
    return (
      <div>
        {
          data.posts.map((post, index) =>
            <Post key={index}
              // {...post} doesn't work
              author={post.author}
              title={post.title}
              tags={post.tags}
              date={post.date}
            />
          )
        }
      </div>
    )
  }
}

Finally, the child component Post for reference. Even with props set within the render function, via data, the spread syntax won't work:

export default {
  name: 'Post',
  props: {
    author: String,
    date: String,
    tags: Array,
    title: String
  },
  render (h) {
    const data = {
      author: this.author,
      date: this.date,
      tags: this.tags,
      title: this.title
    }
    return (
      <div>
        <h1>{data.title}</h1>
        <h2>{data.author}</h2>
        <h3>{data.date}</h3>
        {data.tags.map((tag, i) => <h5 key={i}>{tag}</h5>)}
      </div>
    )
  }
}

from babel-plugin-transform-vue-jsx.

oknoorap avatar oknoorap commented on April 27, 2024

I got the same problem.

from babel-plugin-transform-vue-jsx.

nickmessing avatar nickmessing commented on April 27, 2024

If you experience the same problem check #86, will keep that ticket updated.

from babel-plugin-transform-vue-jsx.

Related Issues (20)

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.