React-number-format: Result renderred with renderText function is missing className prop

Created on 12 Nov 2020  路  6Comments  路  Source: s-yadav/react-number-format

Since renderText receives only one argument with formatted text there is no way to pass unhandled props ("otherProps") down.
Imagine code is refactored from:

<NumberFormat 
  displayType="text" 
  className="foo"
  value="123" 
/>

to:

<NumberFormat 
  displayType="text" 
  className="foo"
  value="123" 
  renderText={formattedValue => <span>{formattedValue}</span>} 
/>

After refactoring class wont be renderred.

Proposal is to pass otherProps variable to renderText as well as value. (Im referring to this line)

enhancement

All 6 comments

Make sense. +1

I can see a usecase for this where renderText prop is provided dynamically based on some props.
But in simple case I will suggest to have those props directly on span.

@s-yadav Can I take this up?

Sure @nikhil-varma.

@s-yadav Noticing the name and keeping in mind backward compatibility, would you suggest keeping the name renderText and pass another argument as otherProps is okay or should we add a new Prop/function indicating that the method also returns the props with it?

We can use the same method and pass others props as second parameter.

@fedulovivan This issue is now fixed and changes are merged! Closing this 馃檪

Was this page helpful?
0 / 5 - 0 ratings