// First: import useState. It's a named export from 'react'// Or we could skip this step, and write React.useStateimport React, { useState } from 'react';
import ReactDOM from 'react-dom';
// This component expects 2 props:// text - the text to display// maxLength - how many characters to show before "read more"functionLessText({ text, maxLength }) {
// Create a piece of state, and initialize it to `true`// `hidden` will hold the current value of the state,// and `setHidden` will let us change itconst [hidden, setHidden] =useState(true);
// If the text is short enough, just render itif (text.length <= maxLength) {
return<span>{text}</span>;
}
// Render the text (shortened or full-length) followed by// a link to expand/collapse it.// When a link is clicked, update the value of `hidden`,// which will trigger a re-renderreturn (
<span>
{hidden ? `${text.substr(0, maxLength).trim()} ...` : text}
{hidden ? (
<a onClick={() =>setHidden(false)}> read more</a>
) : (
<a onClick={() =>setHidden(true)}> read less</a>
)}
</span>
);
}
ReactDOM.render(
<LessText
text={`Focused, hard work is the real key
to success. Keep your eyes on the goal,
and just keep taking the next step
towards completing it.`}
maxLength={35}
/>,
document.querySelector('#root')
);
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems
resetting your password contact us
Check Your Email and Click on the link sent to your email