Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Child/attribute based repeating inputs #17

Open
braco opened this issue Oct 13, 2018 · 1 comment
Open

Child/attribute based repeating inputs #17

braco opened this issue Oct 13, 2018 · 1 comment

Comments

@braco
Copy link

braco commented Oct 13, 2018

This would be a big deal if possible:

 const CustomBlock = ({ title }) => <div>{title}</div>

edit.js

        <Repeat>
          <CustomBlock
             title={<Input name="title" />}
          />
        </Repeat>

save.js

   attributes.thing.map(thing => <CustomBlock title={thing.title} />)

It would mean that you could have repeating custom components and edit them in place. The base component wouldn't need to have any knowledge of Wordpress.

This is MAJOR missing piece from Gutenberg and it should probably be in core, IMO.

Am I right in thinking this isn't possible with the current patterns you're using? None of the child iteration / cloning you're doing will work, unfortunately, unless the parent CustomBlock was modified.

@braco braco changed the title Child-based Repeating Inputs Child/attribute based repeating inputs Oct 13, 2018
@zackify
Copy link
Owner

zackify commented Oct 15, 2018

Hey, I get what you’re saying a little bit, but I’m also confused. You want to repeat your own components, and then map over an array and return those components for the save method?

That should all work fine, thinking off the top of my head here. Just need a Repeat component that works the way you want. I’m not sure exactly what you want the repeat to do in this case. Feel free to reply with more info and I’ll try to help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants