Provide react-bootstrap Level of Support
As raised by @richtera - the library lacks Typescript definitions, and does not support the use of ref as our functional components need to make use of React.forwardRef.
- [x] Rewrite the project in Typescript.
- [ ] Rewrite components in terms of
React.forwardRefwhere needed.
See:
- https://github.com/SimpleSigner/react-bootstrap-drawer/issues/1
- https://github.com/SimpleSigner/react-bootstrap-drawer/pull/2
- https://github.com/react-bootstrap/react-bootstrap/blob/0765f8a1dec691f10e22a8aaaa22607fb9d77b49/src/Button.tsx#L76
See: https://www.carlrippon.com/creating-react-and-typescript-apps-with-webpack/
The following is required to support JSX syntax inside of .ts files, it appears @babel/preset-typescript expects one to use the .tsx file extension to automagically pick up on the syntax. Without this configuration, the transpiler assumes the <div> syntax represents some form of type declaration, rather than JSX for a <div> element.
[
'@babel/preset-typescript',
{
allExtensions: true,
isTSX: true,
}
],
See: https://babeljs.io/docs/en/babel-preset-typescript
One will need to use a multi-phase compilation project, first using tsc (via npm install --save-dev typescript) to type check the project and generate the type definitions, second using Webpack / Babel to generate the JS bundle.
See: https://www.typescriptlang.org/docs/handbook/babel-with-typescript.html
The forwardRef issue was not specifically because of references but because of a mismatch between react-bootstrap versions.
Added a peerDependency definition to avoid this problem in the future.
See: https://github.com/SimpleSigner/react-bootstrap-drawer/pull/4