GeekyAnts / GeekyAnts/NativeBase
Documentation - Using Factory on Text Input
- Dominant language
- TypeScript
- Stars
- 20.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
### Description
The documentation (on the website) for "Using ref" where the Factory function is used on a Text Input component needs to be changed.
The example works, BUT if you build upon it, you will run into all sorts of problems involving re-rending, focus issues, loss of state values, etc... I spent the past couple days trying to fix the problem.
**If you are having focus lose problems and tried everything...** move the Factory OUTSIDE your component function.
As soon as you make NBInput a controlled component you'll have all sorts of problems. Moving it outside Example( ) avoids the component from being re-created every time your state is updated.
Hopefully this helps and I hope to see the documentation adjusted to help others avoid having the same problems.
Thank you for your time and for reading this.
\- Logan (a.k.a DarkComet)
### Problem Statement
The change is needed for the documentation because it will causes major issues and consequences for those who follow and use them (for this particular example, otherwise documentation is amazing!)
### Proposed Solution or API
`const NBInput = Factory(TextInput)`
This line in the example needs to be moved **OUTSIDE** the Example( ) function.
```
const NBInput = Factory(TextInput);
const Example = () => {
const inputRef = React.useRef(null);
return
{
inputRef.current.focus();
}}>
Set Focus
;
};
```
Link: https://docs.nativebase.io/nativebase-factory
### Alternatives
_No response_
### Additional Information
Please don't take this as a criticism of Native base. **Native base is fantastic and documention is stellar!** Thank you for creating and maintaining such an amazing library!
Contributor guide
Assessment
This issue has not been assessed yet.