diff --git a/src/SelectUsers.js b/src/SelectUsers.js
index 9eb103c..a7cef84 100644
--- a/src/SelectUsers.js
+++ b/src/SelectUsers.js
@@ -1,61 +1,44 @@
-import React from 'react';
+import React, { useState, useEffect } from 'react';
import { Select } from 'evergreen-ui';
-export default class SelectUsers extends React.Component {
- constructor(props) {
- super(props);
+const SelectUsers = ({ isLoading, userId, onChange, users }) => {
+ // const x = useMemo(()=> {return something}, [])
+ const [calculatedUsers, setCalculatedUsers] = useState([]);
- this.state = {
- calculatedUsers: [],
+ useEffect(() => {
+ const expensiveCalculationOnUsers = () => {
+ if (users) {
+ console.log('OMG this takes forever');
+ return users;
+ }
+ return [];
};
- }
- expensiveCalculationOnUsers() {
- if (this.props.users) {
- console.log('OMG this takes forever');
- return this.props.users;
- }
- return [];
- }
+ setCalculatedUsers(expensiveCalculationOnUsers());
+ }, [users]);
- componentDidMount() {
- this.setState({
- calculatedUsers: this.expensiveCalculationOnUsers(),
- });
- }
+ return (
+
+ );
+};
- componentDidUpdate(prevProps) {
- if (prevProps.users !== this.props.users) {
- this.setState({
- calculatedUsers: this.expensiveCalculationOnUsers(),
- });
- }
- }
-
- render() {
- const { isLoading, userId, onChange } = this.props;
-
- return (
-
- );
- }
-}
+export default SelectUsers;
diff --git a/src/index.js b/src/index.js
index e21dc64..a4666ac 100644
--- a/src/index.js
+++ b/src/index.js
@@ -4,7 +4,7 @@ import App from './App';
import { hijackEffects } from 'stop-runaway-react-effects';
if (process.env.NODE_ENV !== 'production') {
- hijackEffects();
+ hijackEffects({ callCount: 30, timeLimit: 6000 });
}
const rootElement = document.getElementById('root');