giorgosart / react-easy-edit

Inline editing library for React
https://giorgosart.gitbook.io/react-easy-edit/
MIT License
249 stars 45 forks source link

How to use custom field values - that are not string, number or array? value doesn't accept an object #70

Closed panigrah closed 4 years ago

panigrah commented 4 years ago

Sorry for the lack of description. I have a composite input field that is an object which includes an id, a label, an url. I need to pass the entire object to editComponent and displayComponent.

Although the code works - I get proptype warnings - is it okay to continue using or can we add support for value of type object.

Warning: Failed prop type: Invalid prop `value` supplied to `l` in l (at View.js:201)

I think this is because the PropTypes for value do not accept PropTypes.object. My code is below


const value = { id: 1, name: 'Jacque Solberg', photo: 'http://random.url.com/jacque.jpg' };
<EasyEdit
      type={Types.TEXT}
      value={project.recruiter}
      editComponent={<UserInput  />}
      displayComponent={<UserDisplay />}
/>

const UserDisplay = ({id, name, photo}) => <div><img src={photo} />{name}</div>
const UserInput .... is a drop down select that filters for user names and calls setParentValue(user);
giorgosart commented 4 years ago

Hey @panigrah thank you for logging a ticket, let me review it and i will get back to you as soon as possible.

giorgosart commented 4 years ago

Hey @panigrah I can easily allow PropTypes.object for the value prop, should be able to get this out tonight for you

giorgosart commented 4 years ago

Hey @panigrah, issue is now fixed as part of 1.8.1