-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This works but is slow to render large updates
- Loading branch information
1 parent
129708c
commit 6f05f0a
Showing
9 changed files
with
104,428 additions
and
18 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package-lock=false | ||
engine-strict=true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
21.5.0 |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react'; | ||
import { ListGroup, ListGroupItem, Accordion, Button, Form } from 'react-bootstrap'; | ||
import dictionary from './dictionary.json'; | ||
|
||
function RegexWidget(props) { | ||
const [result, setResult] = React.useState([]); | ||
const [regex, setRegex] = React.useState("Enter regex"); | ||
const [useFixedLength, setUseFixedLength] = React.useState(false); | ||
|
||
const handleSubmit = async (event) => { | ||
const regexp = new RegExp(useFixedLength ? '^' + regex + '$' : regex, 'ig'); | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
setResult(dictionary.filter(a => regexp.test(a))); | ||
}; | ||
|
||
const handleRegexChanged = (e) => { | ||
console.log(e); | ||
setRegex(e.target.value); | ||
}; | ||
|
||
const handleFixedLengthCheckboxChange = (e) => { | ||
console.log(e); | ||
setUseFixedLength(e.target.value); | ||
}; | ||
|
||
return <div className='RegexWidget'> | ||
<Form> | ||
<Form.Group className="mb-3" controlId="formBasicEmail"> | ||
<Form.Check label="Fixed length" onChange={handleFixedLengthCheckboxChange} /> | ||
<Form.Control type="email" placeholder="Enter regex" onChange={handleRegexChanged} /> | ||
</Form.Group> | ||
|
||
<Button variant="primary" type="submit" onClick={handleSubmit}> | ||
Submit | ||
</Button> | ||
</Form> | ||
<ListGroup> | ||
|
||
{ | ||
result.map((a) => { | ||
return <ListGroup.Item key={a}>{a}</ListGroup.Item>; | ||
}) | ||
} | ||
</ListGroup> | ||
</div>; | ||
} | ||
|
||
export default RegexWidget; | ||
|
Oops, something went wrong.