This package has been deprecated

Author message:

use react-tree-walker instead

react-walk

0.0.3 • Public • Published

react-walk

react-walk exposes a couple functions to help you read and manipulate ReactElements as trees.

All this shit is under construction get out of here.

Example

import React from 'react';
import * as ReactWalk from './src/react-walk';
import ReactDOMServer from 'react-dom/server';
 
const page = (
  <html>
    <head>
      <title>I am an html5 page, psych it's me, JSX</title>
    </head>
    <body>
      <div id="poop"/>
    </body>
  </html>
);
 
// NOTE(brian): shit's still kinda low-level but I want to add a bunch more
// functions as we figure out what we're actually creating a library for I dunno
const hydratedPage = ReactWalk.postWalk(page, (elem) => {
  if (elem.props.id === 'poop') {
    return (
      <div>I pooped!</div>
    );
  } else {
    return elem;
  }
});
 
console.log(ReactDOMServer.renderToStaticMarkup(hydratedPage));
// <html><head><title>I am an html5 page, psych it&#x27;s me, JSX</title></head><body><div>I pooped!</div></body></html>

Readme

Keywords

none

Package Sidebar

Install

npm i react-walk

Weekly Downloads

0

Version

0.0.3

License

MIT

Last publish

Collaborators

  • brainkim