Git Product home page Git Product logo

Comments (4)

raphaelpor avatar raphaelpor commented on August 18, 2024 2

Hello @natashache!

Could you please try this?

const customStyles = StyleSheet.flatten({
  unstyled: {
    marginBottom: 7,
    fontSize: 14,
  },
});

It's because the type of the blocks is unstyled. So I think you need to use it in your styles.
πŸ˜‰

from react-native-draftjs-render.

natashache avatar natashache commented on August 18, 2024 1

@Canedo any update on this?

from react-native-draftjs-render.

Canedo avatar Canedo commented on August 18, 2024

Hello @natashache .

I'll take a look about that issue in the next couple days. Can you provide us how your data is coming? How the contentState is on your scenario? It'd help a lot!

Thank you for your issue!

from react-native-draftjs-render.

natashache avatar natashache commented on August 18, 2024

Hi @Canedo

The contentState is from our database, which is stored as string.

After fetching the data from the database, I do this:

            blocks = getRNDraftJSBlocks({
                contentState: JSON.parse(soundcast.long_description),
                customStyles,
            });

where soundcast.long_description is the content state string from the database. And then in render function I have:

                <View style={[styles.section, { paddingTop: 31 }]}>
                    {
                        blocks
                    }
                </View>

Here is an example of JSON.parse(soundcast.long_description). Sorry it's kind of long.

{ entityMap: {},
  blocks: 
   [ { key: 'cb1uu',
       text: 'Despite promises of "fast and easy" results from slick marketers, real personal growth is neither fast nor easy. The truth is that hard work, courage, and self-discipline are required to achieve meaningful results--results that are not attained by those who cling to the fantasy of achievement without effort.',
       type: 'unstyled',
       depth: 0,
       inlineStyleRanges: [Object],
       entityRanges: [],
       data: {} },
     { key: 'acahp',
       text: 'Personal Development for Smart People reveals the unvarnished truth about what it takes to consciously grow as a human being. In this course, you\'ll learn practical, insightful methods for improving your health, relationships, career, finances, and more. You\'ll see how to become the conscious creator of your life instead of feeling hopelessly adrift, enjoy a fulfilling career that honors your unique self-expression, wake up early feeling motivated, energized, and enthusiastic, achieve inspiring goals with disciplined daily habits and much more.',
       type: 'unstyled',
       depth: 0,
       inlineStyleRanges: [Object],
       entityRanges: [],
       data: {} },
     { key: '8t85h',
       text: 'With his refreshingly honest yet highly motivating style, Steve Pavlina will help you courageously explore, creatively express, and consciously embrace your extraordinary human journey.',
       type: 'unstyled',
       depth: 0,
       inlineStyleRanges: [Object],
       entityRanges: [],
       data: {} } ] }

Here is what it looks like when rendered on the web:
screenshot 2018-02-18 11 40 21

And here is what it looks like when rendered on mobile app, using react-native-draftjs-render. As you can see, no space between paragraphs:
img_4693

from react-native-draftjs-render.

Related Issues (20)

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.