Created
October 25, 2019 15:38
-
-
Save porfidev/2408059f2aa7ffd1a1cdd79c4b3e2be5 to your computer and use it in GitHub Desktop.
Complemento para el tutorial del video https://youtu.be/xcFBSCcMfbc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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