How can I use the clipboard in reactnative?

Viewed 85

I am trying to use clipboard copy and paste in textInput.

so i add selectTextOnFocus={true} in textinput (which is RecipeExplain)

However, if i press the textinput window and wait, the copy paste modal does not appear.

After entering and erasing some text string, press the textinput window and wait then clipboard modal appears.

how can i fix this problem?

I want to make the clipboard modal appear on the first try.

this is my code

    import React, {useCallback, useState} from 'react';
    import styled from 'styled-components/native';
    import {ScrollView} from 'react-native';

    const Container = styled.View``;

    const EexContainer = styled.View`
      width: 100%;

      height: 1000px;
      border: 2px solid lightgray;
      border-radius: 40px;
    `;

    const RecipeExplain = styled.TextInput`
      text-align: center;
      font-size: 18px;
    `;

    const Upload = () => {
      const [recipe, setrecipe] = useState('');

      const onChangerecipe = useCallback((e) => {
        setrecipe(e.nativeEvent.text);
      });

      return (
        <Container>
          <ScrollView>
            <EexContainer>
              <RecipeExplain
                selectTextOnFocus={true}
                selectionColor="#d5e8d9"
                style={{textAlignVertical: 'top'}}
                multiline={true}
                numberOfLines={4}
                placeholder={`write what you want
        `}
                value={recipe}
                onChange={onChangerecipe}
              />
            </EexContainer>
          </ScrollView>
        </Container>
      );
    };

    export default Upload;
0 Answers
Related