Skip to content

A reusable dumb/presentational map component for react.js

Notifications You must be signed in to change notification settings

umair-khanzada/react-map-component

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

react-map-component

A reusable dumb/presentational map component for react.js


Demo


props:

Name Type Default Required Priority Details
data array none true none Array of strings, numbers or objects.
returnCustomElement func none false 5
highest priority for now
A function that return an html element or react component, it is call with three arguments.
  1. current element
  2. index
  3. props Object
keys array of string none false 4 A array of keys name that you want to add on DOM.
Note: pass only when data is array of objects
specialClasses boolean false false none Add special classes on some elements same as ng-repeat.
Ex: $first, $middle and $last
parentClass string map-parent false none css class for root/parent element of map-component.
parentTag enum div false none html tag for parent element of map-component, supported tags for now. ['div', 'ul', 'ol', 'tbody', 'thead']
childClass string map-item false none css class for child element, applied on each child of map-component.
childTag enum depends on parentTag false none html tag for child element of map-comonent, supported tags for now. ['h1','h2','h3','h4','h5','h6', 'div', 'section', 'span', 'li', 'tr']
handleClick func (item, index) => {} false none click handler for child element of map-component.
Note: call with two arguments.
  1. item
  2. index

//simple with string.
<MapComponent data={arrayOfString} />

//with objects you need to pass some props like below.
<table>
  <MapComponent data={arrayOfObj} keys={['id', 'name', 'gender']} />
</table>

//with custom element just pass the func no worries which type of data array contain.
<MapComponent data={exampleWithNumber} returnCustomElement={func}/>

About

A reusable dumb/presentational map component for react.js

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published