Skip to content

Instantly share code, notes, and snippets.

View ebrugulec's full-sized avatar
💃

Ebru Gulec ebrugulec

💃
  • Berlin, Germany
View GitHub Profile
const Lazycomponent = React.lazy(()=>import('./lazy.component.js'))
function AppComponent() {
return (
<div>
<Suspense fallback={<div>loading ...</div>}>
<LazyComponent />
</Suspense>
</div>)
}
//React.lazy() kullanılmadan
import OtherComponent from './OtherComponent';
const MyComponent = () => (
<div>
<OtherComponent />
</div>
)
//React.lazy() kullanıldığında
import Loadable from 'react-loadable';
const LoadableDescription = Loadable({
loader: () => import('./Description'),
loading() {
return <div>Loading...</div>;
},
});
function App() {
const LoadDescription = () => import('./Description');
class App extends React.Component {
state = {
Description: null,
};
componentDidMount() {
LoadDescription.then(Description => {
this.setState({ Description: Description.default });
-import Description from './Description';
+const Description = import('./Description');
// index.js
export default () =>
(<Switch>
<Route path='/about' component={About} />
<Route path='/products' component = {Products} />
<Route path='/settings' component = {Settings} />
</Switch>)
// about.js
class About extends Component{
render() {
<input type="number" value="2" min="0" max="40" />
PasswordGenerator.propTypes = {
length: PropTypes.number,
digitCount: PropTypes.number,
symbolCount: PropTypes.number,
maxLength: PropTypes.number,
maxDigits: PropTypes.number,
maxSymbols: PropTypes.number
}
PasswordGenerator.defaultProps = {
const handleOnChange = (e, name) => {
let value = e.target.value
if(name === 'length'){
setLength(value)
}else if(name === 'digits'){
setDigitCount(value)
}else if(name === 'symbols'){
setSymbolCount(value)
}
}
const checkPasswordStrength = () => {
...
setStrengthScore(10)
setStrengthText('weak')
}
const copyToClipboard = () => {
...
setCopy(true)
setTimeout(() => {