Это мое окончательное решение, основанное на ответе Тони:
template <typename T>
std::string stringForNumber( T f, int precision /* = 0 */, bool fixedWidth /*= false*/ )
{
std::ostringstream ss;
ss.setf(std::ios_base::fixed);
if (precision > 0)
ss << std::setprecision(precision);
ss << f;
std::string str(ss.str());
if (!fixedWidth) // Removing trailing 0
{
const auto pointLocation = str.find_first_of(".,");
if (pointLocation != std::string::npos)
{
const auto lastZeroPos = str.find_last_of('0');
const auto lastNotZeroPos = str.find_last_not_of('0');
if (lastNotZeroPos == pointLocation) // Integer number
str.erase(pointLocation);
else if (lastZeroPos != std::string::npos && lastNotZeroPos != std::string::npos && pointLocation < lastZeroPos && lastNotZeroPos < lastZeroPos)
{
str.erase(lastNotZeroPos+1);
}
}
}
return str;
}
проблема:
<Table usersList="{test}" />
исправить:
<Table usersList={test} />
Проблема в том, как вы передаете опору, которая имеет форму струны. Вместо этого вам нужно написать
<Table usersList={test} />
Как только вы сделаете вышеуказанные изменения, вы можете просто получить доступ к элементам массива, сопоставив реквизиты, как
this.props.usersList.map(...)