Code Monkey home page Code Monkey logo

complete-mentions's Introduction

React Native Complete Mentions

A React Native component that let's you mention people in a TextInput like you are used to on Facebook or Twitter.

Getting started

Install the react-native-complete-mentions package via npm:

npm install react-native-complete-mentions --save

Or yarn:

yarn add react-native-complete-mentions

The package exports 2 components

import { MentionInput, Tag } from 'react-native-complete-mentions';

MentionInput is the main component rendering the textarea control. It takes one or multiple Mention components as its children. Each Tag component represents a data source for a specific class of mentionable objects, such as users, template variables, issues, etc.

<MentionInput value={this.state.value} onChangeText={this.handleChange}>
  <Tag trigger="@" renderSuggestions={this.renderUserSuggestion} />
  <Tag tag="#" renderSuggestions={this.renderTagSuggestion} />
</MentionInput>

Examples

Expo Snack: https://snack.expo.io/@pr3k0/react-native-complete-mentions-examples

Please find the examples under the /examples folder

Configuration

The MentionInput supports the following props for configuring the widget:

Prop name Type Default value Description
value string '' The value containing markup for mentions
onChangeText function (string) empty function A callback that is invoked when the user changes the value in the mentions input
inputRef React ref undefined Accepts a React ref to forward to the underlying input element (optional)
onExtractedStringChange function (string) undefined Extract the formated text when the displayed input changes. (optional)

Each data source is configured using a Tag component, which has the following props:

Prop name Type Default value Description
tag string '@' Defines the char sequence upon which to trigger querying the data source
renderText function(mention): ReactTextNode null Allows customizing how mentions are displayed.
renderSuggestions function ({ tracking, keyword, commit }) null Allows customizing how mentions list are rendered (optional)
formatText function(string): string null Allows customizing the mentioned text. (optional)
extractString function(mention): string null Allows customizing the extracted string, for example extractString={mention => `@[${mention.name}](id:${mention.id})`} (optional)
extractCommit function(commit) null Allows you to extract the commit (insert new mention) functionality. (optional)

complete-mentions's People

Contributors

david-szabo97 avatar preko96 avatar

Stargazers

Andrei Bacescu avatar Lucas Marandat avatar Jean avatar

Watchers

 avatar

complete-mentions's Issues

Passing predefined text

Hello! The component works pretty well in almost every case. But it looks like it doesn't handle predefined text. E.g. editing existing message with mention. I guess the component should be able to work with extracted text and transform it into the visible one. How is it supposed to be solved? Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.