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

Support strings as children #16

Closed

Conversation

bclinkinbeard
Copy link

This adds support for translating the following schema into markup like <p>This paragraph has <a href="http://google.com">a link</a> inside it.</p>.

{
  component: 'p',
  children: [
    'This paragraph has ',
    {
      component: 'a',
      href: 'http://google.com',
      text: 'a link'
    },
    ' inside it'
  ]
}

It seems like this kind of thing should definitely be supported since React supports it as seen in this Babel REPL link.

The question it raises is what about the "special" text property? Should it be removed or should both formats be supported?

Happy to add tests and stuff if you want to accept this change.

This adds support for markup like `<p>This paragraph has <a href="http://google.com">a link</a> inside it.</p>`.
@eiof
Copy link
Collaborator

eiof commented Aug 21, 2017

This looks good. I think it'd make sense to move away from text, but for now we should support both. A strategy can be made for deprecating text, such as printing console warnings and having a planned release for dropping it.

Could you add tests? I can merge after that.

@eiof eiof added this to the 1.1.0 milestone Aug 21, 2017
@bclinkinbeard
Copy link
Author

Just a heads up that I don't think I'll be fleshing this out. Jasmine appears to swallow console.log statements in the code under test, which makes debugging super difficult.

@eiof
Copy link
Collaborator

eiof commented Sep 1, 2017

@bclinkinbeard While I was working on a test, I had some thoughts. I understand your reasoning for wanting this feature, but the intention of react-json-schema is to accept JSON.

This library constructs React elements from JSON by mapping JSON definitions to React components that you expose.

It's less about being an alternative API for React's createElement. We chose to build our tool this way so we can feature schema validation.

I see you've already forked react-json-schema for your own use, which I think is for the best. I did get a test working around our planned 1.1.0 release integrated with this concept, in case you want to use that. You can fork it here: https://github.com/TechniqueSoftware/react-json-schema/tree/patch-1-a

I'm still open to ideas or suggestions, but for now I'm closing this issue.

@eiof eiof closed this Sep 1, 2017
@eiof eiof removed this from the 1.1.0 milestone Sep 1, 2017
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

Successfully merging this pull request may close these issues.

None yet

2 participants