Comments (6)
autoEscape={true}
helps to avoid these types of errors if you don't need to process regular expressions, maybe make it true by default?
from react-native-highlight-words.
hello, the problem is when searchWords contain "+"
this is how i get the error :
this.state.valueForModal = "+ Lab"; // the content is filled from user input searching for string starting with '+ lab'
const display = "+ Laburnocytisus adami" ;
<Highlighter
highlightStyle={thisstyles.highlighter}
searchWords={[this.state.valueForModal]}
textToHighlight={display}
style={thisstyles.fontSize15}
/>
from react-native-highlight-words.
Tested "+ Laburnocytisus adami" as textToHighlight prop, cannot reproduce.
from react-native-highlight-words.
I got that bug when I type "+" or "*" into the search words.
I think you should catch some special characters in Regular expression
For hotfix we can replace the search key before assign to the searchWords like the code bellow:
let searchKey = props.searchKey ? props.searchKey : ""
const specialKey=["[", "?", "+", "*"]`
for(i = 0 ; i < specialKey.length; i++ ) {
searchKey = searchKey.replace(specialKey[i],'\\'+specialKey[i])
}
from react-native-highlight-words.
I tested with this:
<Highlighter
style={{ color: '#888', fontSize: 13, fontFamily: 'System', padding: 10 }}
highlightStyle={{ backgroundColor: '#FEF3A2' }}
numberOfLines={3}
ellipsizeMode="middle"
searchWords={["+ Lab", "* Lab", "? Lab", "[ Lab"]}
textToHighlight={"+ Laburnocytisus adami"}
autoEscape={true}
/>
I get:
No error, so I still can't reproduce. My env:
React Native 0.57.0
> react-native info
React Native Environment Info:
System:
OS: Windows 10
CPU: x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
Memory: 4.65 GB / 15.95 GB
Binaries:
Yarn: 1.12.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
from react-native-highlight-words.
Yes, it would be nice.
from react-native-highlight-words.
Related Issues (20)
- Implement to <Textarea>
- How can we add Padding and other styles into highlighted words? HOT 2
- Is it possible to set property of Text components like numberOfLines, ellipsizeMode to Highlighter HOT 1
- Add multiple styles to other words HOT 1
- Release new version
- how to get total count of highlighted word. HOT 1
- Please add autoEscape={true} in README HOT 1
- Scrollto highlight word
- input '.' and it will all be highlighted HOT 1
- Text strings must be rendered within a <Text> component
- How could I just highlight the exat word? HOT 3
- chore: add ts support HOT 1
- Can we add onPress for highlight text? HOT 1
- Any way to add an ellipses effect to the text passed to the highlighter? HOT 1
- warning " > [email protected]" has incorrect peer dependency "react@^15.5.0". HOT 3
- Update the package to use deprecated-react-native-prop-types and keep compatibility with react native 0.69.x HOT 1
- ERROR TypeError: undefined is not an object (evaluating '_reactNative.Text.propTypes.style') in react native 0.70 HOT 1
- Is this package still be maintained? HOT 1
- Expose React Native <Text/> props to highlighted words HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-highlight-words.