React Ordinals is a package used to get number ordinals in react apps
Install the package using npm:
npm install react-ordinals
Install the package using yarn:
yarn add react-ordinals
Install the package using bun:
bun add react-ordinals
Here's a basic example of how to use react-ordinals
:
import React from "react";
import { WordOrdinal } from "react-ordinals";
const App = () => {
const numberRange = Array.from({length: 50}, (_, index) => index + 1);
return (
<section>
{numberRange.map((number) => (
<WordOrdinal
number={number}
shouldBeTitleCase={true}
/>
))}
</section>
);
};
export default App;
The WordOrdinal
component is responsible for converting numbers into their ordinal form.
Props:
-
number
(required): The number to be converted into an ordinal form. -
shouldBeTitleCase
(required): A boolean indicating whether the result should be in title
const App = () => {
return (
<section>
<WordOrdinal
number={14}
shouldBeTitleCase={false}
/>
</section>
);
};
Contributions are welcome! Feel free to open an issue or submit a pull request.