0.3.1 • Published 1 year ago
react-ordinals v0.3.1
React Ordinals
React Ordinals is a package used to get number ordinals in react apps
Installation
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
Usage
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;
API
WordOrdinal
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
Examples
Example 1: Word Ordinal
const App = () => {
return (
<section>
<WordOrdinal
number={14}
shouldBeTitleCase={false}
/>
</section>
);
};
Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request.