Skip to content

Typecasting for attributes #19

Description

@PixelsCommander

At the moment attribute always reflect in this.porps as a string. But in order to use React components without changes we need to configure typecasting for attributes.

There are few propositions from Thomas Reggi on how to make this work:

This would solve the issue of [attribute casing] issue and the [required integer type] issue and would validate for the timer element and fulfill it's propTypes / initialTimeRemaining: React.PropTypes.number.isRequired.

The only problem with this would be if there was a conflict with a library that had a prop with the keyword reactive.

Would love your thoughts on this!!

<react-timer initial-time-remaining="600000">
</react-timer>

Besides the attribute json above. thinking

<react-timer initial-time-remaining="600000" initial-time-remaining-type="number">
</react-timer>

or

<react-timer initial-time-remaining="num!600000">
</react-timer>

or

<react-timer initial-time-remaining="600000" initial-time-remaining-transform="parseInt(this, 10);">
</react-timer>

or keep this logic out of the tag and put it in when registering

registerReact('react-timer', timerClass, {
  "initialTimeRemaining": function(props){
    return parseInt(props.initialTimeRemaining, 10);
  }
});

The last one there would also let you return a function as a prop, which is better then in the attributes.

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