Skip to content

Instantly share code, notes, and snippets.

@porfidev
Created October 25, 2019 15:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save porfidev/2408059f2aa7ffd1a1cdd79c4b3e2be5 to your computer and use it in GitHub Desktop.
Save porfidev/2408059f2aa7ffd1a1cdd79c4b3e2be5 to your computer and use it in GitHub Desktop.
Complemento para el tutorial del video https://youtu.be/xcFBSCcMfbc
import React from "react";
import "./App.css";
function FormatNumber({ number }) {
return (
<span style={{ color: "red" }}>
{new Intl.NumberFormat("ES-MX", {
style: "currency",
currency: "MXN"
}).format(number)}
</span>
);
}
class App extends React.Component {
state = {
number: 0
};
handleChange = event => {
this.setState({
number: event.target.value > 999999999 ? 999999999 : event.target.value,
});
};
render() {
const { number } = this.state;
return (
<div className="App">
<h1>
Hola dinero <FormatNumber number={number} />
</h1>
<input type="number" onChange={this.handleChange} />
</div>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment