0

I'm trying to use the Bootstrap datepicker function for react. I implemented the solution from the following thread: React DatePicker Bootstrap up to date.

The import looks like:

import Form from 'react-bootstrap/Form';
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
import '../../../node_modules/bootstrap/dist/css/bootstrap.min.css'

And my code currently looks something like:

return(
        <Form>
            <Row>
                <Col xl={5} lg={5}>
                    <Form.Group as={Row} controlId="fcField">
                       <Form.Label column xl={3} lg={3} className="mr-1">Form Label:</Form.Label>
                       <Col xl={9} lg={9}>
                       <Form.Control 
                        size="sm" 
                        type="date" 
                        readOnly={!editFlag} 
                        name="shipdate"                  
                        value={convertDate(selectedBuild.shipdate ? selectedBuild.shipdate : '', '-')}
                        onChange={onChangeHandler}
                        onBlur={dateBlurHandler}
                        />
                        </Col>
                    </Form.Group>
                </Col>
           </Row>
        </Form>
     )

But the "date" type only renders the browser default, seen in this picture.

enter image description here

From my understanding, it should look like what is in the bootstrap document:

enter image description here

There are many aspects of the bootstrap datepicker that I would like to use, and they are not taken as arguments into my Form.control.

From the previous forum post, it looked like all I had to do was set the form.control type to "date". But apparently that is not happening.

What can I do to access the bootstrap datepicker?

Andrew
  • 43
  • 1
  • 6

1 Answers1

0

I would try using react-bootstrap-date-picker as it's the accepted answer on the thread you linked. https://www.npmjs.com/package/react-bootstrap-date-picker

pzutils
  • 490
  • 5
  • 10
  • I figured that since this project doesn't appear to have a commit since 2016 that it may no longer be supported. – Andrew Oct 11 '22 at 23:43
  • Example: ./node_modules/react-bootstrap-date-picker/lib/index.js Module not found: Can't resolve 'react-bootstrap/lib/Button' in '<...path>\node_modules\react-bootstrap-date-picker\lib' – Andrew Oct 11 '22 at 23:46
  • You could try forking this project so it works with a newer version of react-bootstrap - it looks like you might just need to change the imports form react-bootstrap/lib/ to react-bootstrap/ - that should definitely resolve the import errors at least – pzutils Oct 12 '22 at 00:45
  • I wish that it was as simple as that. Certainly I did fix the react-bootstrap paths, but there appear to also be other prop issues: "Cannot read properties of undefined (reading 'object')". It seems to point to "selectedDate" or "displayDate" except that these are not part of the documentation or the initial examples used to construct the date picker. – Andrew Oct 12 '22 at 18:34