shshaw / Splitting

JavaScript microlibrary to split an element by words, characters, children and more, populated with CSS variables!

Home Page:https://splitting.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Splitting() in React's componentDidMount not working

onetwothreebutter opened this issue · comments

Hi, thank you guys for this great library! I'm trying to use it in a React/GastbyJS project with this code:

class WorkIveDonePage extends React.Component {
    componentDidMount() {
        Splitting();
    }

    render() {
        return (
            <div>
                <section className="work__banner">
                    <div className="work__page-width">
                        <h1 className="site__banner-heading" data-splitting>

and I get the following error:
screen shot 2018-09-02 at 1 57 15 pm

Does this look like a bug or something on my side?

commented

React is translating data-splitting to data-splitting=“true”. If you set it to chars or an empty string it should work properly. We are looking at making the error reporting better for this.

commented

Also we are tracking the error reporting in this issue: #27

commented

Yes, it's an issue with React's treatment of properties and how we're detecting the split to use. I would recommend a bit more specific targeting of the element to be split, perhaps using React's Refs and Splitting({ target: this.myRef }) to prevent splits running/re-running outside of your component.

Let us know if you have any questions, @onetwothreebutter!