carlrip / LearnReact17WithTypeScript

MIT License
57 stars 44 forks source link

defaultProps type value have no effect #5

Closed wflixu closed 5 years ago

wflixu commented 5 years ago

in chapter 7, I set default type like this

Form.Field.defaultProps = {
    type: 'Text'
};

but ,have no effect

wflixu commented 5 years ago

sorry, I found It's my code error

//before
  {(type === 'Text') || (type === 'Email') && (
             <input type={type.toLowerCase()} id={name} value={context.values[name]}
                onChange={e => handleChange(e, context)} />
)}

// right code
  {(type === 'Text' || type === 'Email') && (
          <input type={type.toLowerCase()} id={name} value={context.values[name]}
          onChange={e => handleChange(e, context)} />
)}