Created
August 2, 2019 08:38
-
-
Save ngohungphuc/fdbff75c1b364863577ae1221d3034fa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function Example({text, maxLength}) { | |
| // define hidden state default init value is true and | |
| // setHidden function to update state | |
| const [hidden, setHidden] = useState(true); | |
| // on click we change the state of hidden and trigger re-render of the view | |
| return ( | |
| <span> | |
| {hidden ? ( | |
| <a onClick={() => setHidden(false)}> read more</a> | |
| ) : ( | |
| <a onClick={() => setHidden(true)}> read less</a> | |
| )} | |
| </span> | |
| ); | |
| } | |
| export default Example; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment