Skip to content

allow to pass value as props #34

Open

Description

@fdecampredon
<FormatDate options={{date: 'short'}} >{date}</FormatDate>

can feel a bit awkward could this module also support this api ?

<FormatDate value={date} options={{date: 'short'}} />

Activity

  1. rxaviers commented on Dec 16, 2015

    @rxaviers
    Member

    Hi,

    Currently, whatever is passed in value gets overwritten by children (code below). We could change the below for not overwritten args[0] if children is falsy. so we enable both usages in your description.

    // src/generator.js:
    this.args[0] = this.props.children;

    Would you like to submit a pull request with such change?

  2. fdecampredon commented on Dec 16, 2015

    @fdecampredon
    Author

    I'll do so !

  3. kborchers commented on Mar 11, 2016

    @kborchers
    Collaborator

    Hi @fdecampredon. Are you still interested in working on this?

  4. cowboy commented on Mar 11, 2016

    @cowboy

    I had the same question. I'd love to see this implemented. Basically, use this.props.value if set, otherwise use this.props.children.

  5. gnarf commented on Mar 11, 2016

    @gnarf

    I actually think that you should only allow value= prop and deprecate the children format.

  6. cowboy commented on Mar 11, 2016

    @cowboy

    I actually think that you should only allow value= prop and deprecate the children format.

    👍 to that

  7. rxaviers commented on Mar 15, 2016

    @rxaviers
    Member

    @gnarf I see you have a preference, but the motivation isn't clear to me. Using a value attribute instead of children might be convenient in the given example (I agree), but using the opposite (children instead of a value attribute) might be convenient in other cases like:

    <FormatMessage>You’re receiving notifications because you commented</FormatMessage>

    I hold my preference for "use this.props.value if set, otherwise use this.props.children". I don't see any problem with allowing both options this way.

    PRs are still very welcome. Thanks

  8. kborchers commented on Mar 15, 2016

    @kborchers
    Collaborator

    I agree with @rxaviers here. I am working on adding some initial tests to the repo (PR almost ready) and then I will add this "use this.props.value if set, otherwise use this.props.children" functionality along with additional tests

  9. added a commit that references this issue on Mar 16, 2016
    92eadf2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions